C Programming - Bitwise Operators - Discussion
Discussion Forum : Bitwise Operators - Point Out Correct Statements (Q.No. 1)
1.
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
unsigned int num;
int i;
scanf("%u", &num);
for(i=0; i<16; i++)
{
printf("%d", (num<<i & 1<<15)?1:0);
}
return 0;
}
Answer: Option
Explanation:
If we give input 4, it will print 00000000 00000100 ;
If we give input 3, it will print 00000000 00000011 ;
If we give input 511, it will print 00000001 11111111 ;
Discussion:
19 comments Page 2 of 2.
Vartika said:
7 years ago
I don't understand when I write %u in scanf, how is it behaving like %d?
Prem said:
1 decade ago
If the condition is true it will print as 1 otherwise 0.
Kannan said:
1 decade ago
Why the program print binary value. What cmd?
Rvm said:
7 years ago
%u means? Please explain in detail.
Haritha said:
1 decade ago
Please explain it more clearly.
Ankit said:
1 decade ago
Please explain it clearly.
Bishal said:
8 years ago
What is %u in scanf?
Mohanty said:
1 decade ago
What is "i<16"?
Radhey said:
7 years ago
Unsigned means?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers