CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

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.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Importance of Planning
BUSINESS STUDIES
Watch in App
Join BYJU'S Learning Program
CrossIcon