Single Choice
Not Set
QWhich of the following statements are correct about the program?
#include
int main()
{
unsigned int num;
int c=0;
scanf("%u", &num);
for(;num;num>>=1)
{
if(num & 1)
c++;
}
printf("%d", c);
return 0;
}
ID: #1208
Operators and Enums in C Language
1,318 views
Question Info
#1208Q ID
Not SetDifficulty
Operators and Enums in C LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
Option A:
If we give input 4, it will print 1.
Binary-4 == 00000000 00000100 ; Total number of bits = 1.
If we give input 3, it will print 2.
Binary-3 == 00000000 00000011 ; Total number of bits = 2.
If we give input 511, it will print 9.
Binary-511 == 00000001 11111111 ; Total number of bits = 9.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic