Solution for Exercise 11-6
ex1106
#include <stdio.h>
int main()
{
int a,b;
b=16;
printf("Before, a is unassigned and b=%d\n",b);
a=++b;
printf("After, a=%d and b=%d\n",a,b);
return(0);
}
Output
Before, a is unassigned and b=16
After, a=17 and b=17
Notes
* Because the ++ (increment operator) appears before variable b at Line 9, its value is incremented first. Then the result is assigned to variable a.
* It's important to remember when a value is incremented or decremented lest your code not behave as intended.
Copyright © 1997-2025 by QPBC.
All rights reserved
