Increment/Decrement Programs

1. Increment Operator

#include <stdio.h>

int main() {

int x = 5, y = 5;

// x is displayed

// Then, x is increased to 6.

printf(“%d post-increment n”, x++);

// y is increased to 6

// Then, it is displayed.

printf(“%d pre-increment”, ++y);

return 0;

}

2. Decrement Operator

#include <stdio.h>

int main() {

int x = 5, y = 5;

// x is displayed

// Then, x is decreased to 4.

printf(“%d post-decrement n”, x–);

// y is decreased to 4

// Then, it is displayed.

printf(“%d pre-decrement”, –y);

return 0;

}


Comments

Popular posts from this blog