What is the output of following program ?
int
main()
{
int x = 5;
printf("%d %d %d\n", x, x << 2, x >> 2);
}
Answers were Sorted based on User's Feedback
Answer / shubham
5
5>>2=1(0000101=>00000001)
5<<2=20(0000101=>10100)
Is This Answer Correct ? | 3 Yes | 0 No |
4 4 1 is the output....
here the operation of STACK involves.... for these kind of statements (ie) statements having multiple values to get printed it is used..... so the very first element that goes inside stack is x , then x<<2 , then x>>2... so from the TOP it will be operated....
and print as the order given in printf statement..... :)
thank u
Is This Answer Correct ? | 6 Yes | 16 No |
Answer / krishna deep sharma
4,4,1
coz we shift the bit as 5=101 now shift two bit to right as
101>>2=001
now
2<<001=100
noe x=4
printf execute from right to left so ans is 4,4,1
Is This Answer Correct ? | 11 Yes | 28 No |
Write a c program to enter a string of paragraph and replacing a particular word which is repeated in the paragraph by another word?
2 Answers ME, Synfusion, Wipro,
What are unions in c?
Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?
what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7
how to find binary of number?
program to find middle element of linklist?
How to get string length of given string in c?
#include<stdio.h> void main() { int =1; printf("%d%d%d",a++,++a,++a); }
what is the output of the code and how? main() { int *ptr,x; x=sizeof(ptr); printf("%d",x); }
void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?
How a string is stored in c?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.