home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch1
/
incremen.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
918b
|
29 lines
/* incremen.c
*
* Synopsis - Assigns values to b using the increment and
* decrement by 1 operators with a. Displays
* values of a and b.
*
* Objective - To demonstrate the increment and decrement by
* 1 operators.
*/
#include <stdio.h>
int main( void )
{
int a = 3, b;
b = a++; /* Note 1 */
printf("b is %d, and a is %d.\n", b, a);
b = ++a; /* Note 2 */
printf("Now b is %d, and a is %d.\n", b, a);
b = 5 % --a; /* Note 3 */
printf("Now b is %d, and a is %d.\n", b, a);
/* Note 4 */
printf("Now b is %d, and a is %d.\n", ++b, a--);
printf("Now b is %d, and a is %d.\n", b, a);
return 0;
}