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 what is operator promotion?
Explain what is a stream?
Is c# a good language?
Tell me with an example the self-referential structure?
What is a newline escape sequence?
What is the use of a static variable in c?
What are the different types of endless loops?
What is the difference between declaring a variable and defining a variable?
can we have joblib in a proc ?
List the different types of c tokens?
Explain how can you restore a redirected standard stream?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
Explain what is the advantage of a random access file?
How can I find out if there are characters available for reading?
What are the disadvantages of external storage class?