home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
98.img
/
LCNOW2.ZIP
/
EXAMPLES
/
PRE&POST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-02-19
|
682b
|
26 lines
/*
* P R E & P O S T
*
* Demonstrate the uses of prefix and postfix notation
* in arithmetic expressions.
*/
main()
{
/* Initialize and declare variables */
int x = 2, y = 3, result;
/* Show values before and after expression evaluation. */
printf("\nSTARTING VALUES: x=%d; y=%d\n", x, y);
result = ++x + y;
printf("PREFIX: The result of ++x + y = %d\n", result);
printf("(After calculation, x=%d and y=%d)\n", x, y);
x = 2, y = 3; /* Restore values */
printf("\nSTARTING VALUES: x=%d; y=%d\n", x, y);
result = x++ + y;
printf("POSTFIX: The result of x++ + y = %d\n", result);
printf("(After calculation, x=%d and y=%d)\n", x, y);
}