increment and decrement operators in c

these operators are used to increment a value by 1 (++) and it uis used to decrement a value by 1 by (โ€“)

increment operator is implimented in two forms

1)pre-increment

here, the value incremented first and and then assigned

example: ++a

a = 5;
b =++a;
result
a=6
b=6
2)post-increment

here, the value is assigned first and the incremented

a = 5;
b =a++;
result
a=6
b=5
3)pre-decrement

here, the value decremented first and and then assigned

a = 5;
b =--a;
result
a=4
b=4
4 )post-decrement

here, the value is assigned first and then decremented

a = 5;
b =a--;
result
a=4
b=5

example:

//codeskulls
#include
int main()
{
int a = 1, b = 2;
float c = 3.7, d = 4.67;
printf("++a = %d \n", ++a);
printf("--b = %d \n", --b);
printf("++c = %f \n", ++c);
printf("--d = %f \n", --d);
return 0;
}
//codeskulls

output:

++a = 2
--b = 1
++c = 4.700000
--d = 3.670000
Press any key to continue . . .