main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}

Answers were Sorted based on User's Feedback



main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

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

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / rahul

5,20,1

Is This Answer Correct ?    50 Yes 3 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / kamalg

5 20 1

Is This Answer Correct ?    16 Yes 2 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / abhishek rai

5201

Is This Answer Correct ?    4 Yes 3 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / a. k

20 1 5

Is This Answer Correct ?    0 Yes 3 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / mukul

5,10,2

Is This Answer Correct ?    3 Yes 11 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

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

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / vignesh1988i

the answer is 0 0 0 ...

thank u

Is This Answer Correct ?    1 Yes 11 No

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / vignesh1998i

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

main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } ..

Answer / jignesh patel

5 5

Is This Answer Correct ?    1 Yes 12 No

Post New Answer

More C Interview Questions

How to removing white spces in c programming only bu using loops

2 Answers  


what is c programing

11 Answers   Wipro,


Explain function?

0 Answers  


What are qualifiers in c?

0 Answers  


#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?

4 Answers   Ramco,






There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.

2 Answers  


What is equivalent to ++i+++j?

0 Answers  


What is meant by int main ()?

0 Answers  


a=0; b=(a=0)?2:3; a) What will be the value of b? why b) If in 1st stmt a=0 is replaced by -1, b=? c) If in second stmt a=0 is replaced by -1, b=?

6 Answers   Geometric Software,


1.Why do you call C is middle level language? 2.Why do you call C is userfriendly language.

2 Answers  


code for find determinent of amatrix

0 Answers  


A.C func() { pritnf(" in fuction %d",MACRO); } MAIN.c testfunc() { #define MACRO 10 printf("in test function %d", MACRO); } main() { printf("in main %d",MACRO); func(); testfunc(); getch(); }

2 Answers   Wipro,


Categories