IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Earn Free Bitcoin
CData Types & Operators ❯ Increment and Decrement
<02.06>
/* Increment (++) and decrement (--) */
#include <stdio.h> int main (void) { int a, b; a = 5; /* increment (++) */ /* a is incremented by 1 */ ++a; printf ("After ++a, a is now %d\n", a); /* a is once more incremented by 1 */ a++; printf ("After a++, a is now %d\n", a); /* a is incremented but b gets the current a */ b = a++; printf ("After b=a++, a is now %d and b is %d\n", a, b); /* a is incremented and b gets the incremented a */ b = ++a; printf ("After b=++a, a is now %d and b is %d\n", a, b); /* decrement (--) */ /* a is decremented by 1 */ --a; printf ("After --a, a is now %d\n", a); /* a is once more decremented by 1 */ a--; printf ("After a--, a is now %d\n", a); /* a is decremented but b gets the current a */ b = a--; printf ("After b=a--, a is now %d and b is %d\n", a, b); /* a is decremented and b gets the decremented a */ b = --a; printf ("After b=++a, a is now %d and b is %d\n", a, b); return (0); }
Hergestellt in Deutschland / Made in Germany
After ++a, a is now 6 After a++, a is now 7 After b=a++, a is now 8 and b is 7 After b=++a, a is now 9 and b is 9 After --a, a is now 8 After a--, a is now 7 After b=a--, a is now 6 and b is 7 After b=++a, a is now 5 and b is 5
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.