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 program using bitwise operators to invert even bits of a given number.
Can you please explain the scope of static variables?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
Can a local variable be volatile in c?
HOW TO HANDLE EXCEPTIONS IN C
program that accepts amount in figures and print that in words
2 Answers Infosys, Lovely Professional University, Wipro,
What does void main return?
What will be the result of the following C language program? main() { int a = 0; int b = 20; char x = 1; char y = 10; if(a,b,x,y) printf("Welcome"); }
Explain what is operator promotion?
what is the difference between exit() and _exit() functions?
When a c file is executed there are many files that are automatically opened what are they files?
What are static functions?