ExamVeda
Login
Home
This question belongs to C Program Control Structures
Control Structures
?

What will be the output of the given program?
#include<stdio.h>
void main()
{
	int a=11,b=5;
	if(a=5) b++;
	printf("%d %d", ++a, b++);
}

Answer & Solution
Correct Answer: Option C

Here if condition evaluates to true as a non-zero value i.e 5 is assigned to a.
So the value of a = 5 and after increment value of b = 6.
In printf statement due to pre-increment of a value of a printed will be 6 and due to post-increment of b value of b printed will be 6 and not 7.

Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.