Computer Science, asked by kaleenbhaiya8484, 2 months ago

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 anindyaadhikari13
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.

  1. Post increment/decrement and,
  2. 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 Thinkab13
0

If a is 15

printf("%d",++a);

printf("%d",a++);

printf("%d",--a);

printf("%d",a--);

Output -

16

15

14

15

Similar questions