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
What do you mean by a local block?
Is it possible to have a function as a parameter in another function?
Is that possible to add pointers to each other?
Why is c so powerful?
What is structure packing in c?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
What should malloc(0) do?
What does c value mean?
Is null always equal to 0(zero)?
What is the difference between procedural and declarative language?
why we wont use '&' sing in aceesing the string using scanf
How would you rename a function in C?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?