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



What is the output of following program ? int main() { int x = 5; printf("%d %d %d..

Answer / qint

5 20 1

Is This Answer Correct ?    72 Yes 6 No

What is the output of following program ? int main() { int x = 5; printf("%d %d %d..

Answer / sudhir prasad

5 20 1 is correct answer

Is This Answer Correct ?    21 Yes 3 No

What is the output of following program ? int main() { int x = 5; printf("%d %d %d..

Answer / shubham

5
5>>2=1(0000101=>00000001)
5<<2=20(0000101=>10100)

Is This Answer Correct ?    3 Yes 0 No

What is the output of following program ? int main() { int x = 5; printf("%d %d %d..

Answer / vignesh1988i

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

What is the output of following program ? int main() { int x = 5; printf("%d %d %d..

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

Post New Answer

More C Interview Questions

why we need function pointers?

3 Answers  


Explain what does the format %10.2 mean when included in a printf statement?

0 Answers  


What is logical error?

0 Answers  


main() { int i=0; while(+(+i--)!=0) i-=i++; printf(i); }

3 Answers  


Program to display given 3 integers in ascending order

1 Answers   N Tech,






How do you determine whether to use a stream function or a low-level function?

0 Answers  


What is the output of the below program and how it is? void main() { static int var=5; printf("%d",var--); if(var) main(); }

8 Answers   MindFire, TCS, Tech Mahindra,


Why we use stdio h in c?

0 Answers  


explain what is an endless loop?

0 Answers  


Can stdout be forced to print somewhere other than the screen?

0 Answers  


define switch statement?

6 Answers   CTS,


write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview

2 Answers   Satyam, UNIS, Wipro,


Categories