[Courses] [C] Chapter 4d
Morgon Kanter
admin at surgo.net
Fri Oct 11 17:09:57 EST 2002
>Can anyone write an easy-to-read program that would show the difference?
>(I'm trying to get YOU actively involved in this "course"... here's
>a hint: declare your variable and initialize it, then printf() the
>value. increment the variable using prefixed `++', then printf()
>the variable again... do the same for postfix and for decrement).
>Show us your source! (Use the source Luke, use the source!)
>May the source be with you!
Here goes.
------------------Start program--------------------
#include <stdio.h>
int main(void) {
int x = 1;
printf("%d\n", x);
x++;
printf(%d\n", x);
x = 1;
++x;
printf("%d\n", x);
}
-----------End Program-------------
The results:
1
2
2
So, x++ and ++x are the same.
More information about the Courses
mailing list