main()
{
int a=5;
printf(?%d,%d,%d\n?,a,a< <2,a>>2);
}
Answer: 5,20,1 please explain this code in detail
Answer Posted / manishsoni
#include<stdio.h>
#include<conio.h>
int main()
{
int a=5;
printf("%d,%d,%d\n",a,a<<2,a>>2);
getch();
return 0;
}
the ans is 5,20,1
How this ans is :
(1) a=5
(2) a=5
____________________
In digit |In binary|
__________|_________|
5 |101 |
__________|_________|
5<<2 |101<<2 |
__________|_________|
20 |10100 |
__________|_________|
(3)
____________________
In digit |In binary|
__________|_________|
5 |101 |
__________|_________|
5>>2 |101>>2 |
__________|_________|
1 |1 |
__________|_________|
----------------------------------------------------------|
<< is left shift operator and behave as : |
it shift the value left side and attached the 0 with right|
side. |
----------------------------------------------------------|
>> is right shift operator and behave as: |
it shift the value right side and attached the 0 with left|
side. |
----------------------------------------------------------
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain how can I remove the trailing spaces from a string?
Why are algorithms important in c program?
c language interview questions & answer
What is string function c?
Is the exit() function same as the return statement? Explain.
What functions are in conio h?
How can I open files mentioned on the command line, and parse option flags?
What is data structure in c and its types?
How to compare array with pointer in c?
Is fortran still used today?
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
Explain what is the use of a semicolon (;) at the end of every program statement?
Explain about C function prototype?
Write programs for String Reversal & Palindrome check
Array is an lvalue or not?