main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
Answers were Sorted based on User's Feedback
Answer / daniel
Indeed the correct answer is 5, 20, 1.
Explanation:
* the value of x is 5 so it will print out 5
* the value of x << 2, x shifted to left 2 times means x multiplied by 2 for 2 times, i.e. 5 * 2 * 2 = 20
* the value of x >> 2, x shifted to right 2 times so the result will be 5 / 2 / 2 = 5 / 4 = 1 (x is an int).
Is This Answer Correct ? | 84 Yes | 2 No |
Answer / anand h i
in printf functiton evaluation of variables start from
right to left so first it evaluates
x>>2
101 after right shift of 2 it will be 001=1
next it will evaluate
x<<2
1 after left shift of 2 it will be 100=4
at the last x=4
so answer is 4 4 1
Is This Answer Correct ? | 3 Yes | 13 No |
oh oh , sorry , i didnt see the value of x is 5....
4 4 1
than k u
Is This Answer Correct ? | 1 Yes | 11 No |
What is meant by inheritance?
What is variable declaration and definition in c?
how can f be used for both float and double arguments in printf? Are not they different types?
what is answer for perfect number????????????????
1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop
how to swap two nubers by using a function with pointers?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
Software Interview Questions
How do you search data in a data file using random access method?
praagnovation
What the advantages of using Unions?
what are two kinds of java