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 |
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
What are the similarities between c and c++?
What is difference between array and pointer in c?
main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); } what is the output?
7 Answers AMCAT, HCL, Ramco, Zycus Infotech,
write a program for the normal snake games find in most of the mobiles.
What is the output of the program given below #include<stdio.h> main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
21 Answers ADITI, Student, TCS,
for questions 14,15,16,17 use the following alternatives:a.int b.char.c.string.d.float
Which of the following about the C comments is incorrect ? a.commentscan go over multiple lines b.comments can start any where in the line c.a line can contain comments with out any language statements d.comments can occur within comments
progrem to generate the following series 1 12 123 1234 12345
Reverse the bit order in a single macro. eg. i/p = 10010101 --> o/p = 10101001
Write a program to check whether a number is prime or not using c?
What is dangling pointer in c?