What is the output of the following program?
#include <stdio.h>
void main ()
{
int a = 5, b =2;
if (a = b)
{
printf("%d",a);
}
else
{
printf("%d",b);
}
}
A
1
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
5
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
Error
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
2
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution
The correct option is D 2 a = b is assignment operation and it's a true operation, hence condition will be true, so value of a (after assignment) is printed.