If a is 15, then what would be the value of:
printf("%d",++a);
printf("%d",a++);
printf("%d",--a);
printf("%d",a--);
Answers
Answered by
2
Answers:
1. printf("%d",++a);
> 16
2. printf("%d",a++);
> 15
3. printf("%d",--a);
> 14
4. printf("%d",a--);
> 15
Explanation:
There are two types of increment and decrement operation.
- Post increment/decrement and,
- Pre increment/decrement.
Post Increment/decrement – Here, the operation takes place at first and then the value of the variable is incremented or decremented.
In second and fourth question, value of a is displayed and then it is incremented and decremented. So, 15 is displayed.
In first and third question, value of a is first incremented/decremented and then it is displayed. So, the output is 16 and 14.
Answered by
0
If a is 15
printf("%d",++a);
printf("%d",a++);
printf("%d",--a);
printf("%d",a--);
Output -
16
15
14
15
Similar questions
English,
1 month ago
Social Sciences,
1 month ago
English,
2 months ago
Sociology,
9 months ago
Math,
9 months ago