Increment Operators
Completed
Read an integer x. Then run a = x++; and b = ++x; and print a, b and x.
Input
One integer.
Output
One line: a b x
Example
Input
5
Output
5 7 7
Editor
C
Hints
x++ gives the old value, then adds 1.
++x adds 1 first, then gives the new value.
Solution explanation
Postfix returns the value before the change; prefix returns it after.
Show solution
#include <stdio.h>
int main() {
int x, a, b;
scanf("%d", &x);
a = x++;
b = ++x;
printf("%d %d %d\n", a, b, x);
return 0;
}