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 value1, value2=100, num=100;
	if(value1=value2%5) num=5;
	printf("%d %d %d", num, value1, value2);
}

Answer & Solution
Correct Answer: Option D

Expression value2%5 is equal to 0 and this value assigned to value1.
Therefore if condition reduces to if(0) so it fails.
Therefore body of if will not be executed i.e num = 5 will not be assigned.
So at printf num = 100 , value1 = 0 and value2 = 100.

Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Ravindra Mulane
Ravindra Mulane 8 years ago
2%5 is 2 & not 0
Satyendra Gupta
Satyendra Gupta 9 years ago
10 0 100