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

What is a stream water?

0 Answers  


sir i got 146 correct question & i have also the advantage of height so will they consider my marks as 146+3=149.can any body tell me how they consider my height marks.

1 Answers  


Which header file is used for clrscr?

0 Answers  


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

0 Answers  


Explain what is gets() function?

0 Answers  






what is the use of ‘auto’ keyword?

1 Answers  


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

0 Answers   ADP,


difference between Low, Middle, High Level languages in c ?

0 Answers   Bosch, Infosys,


please give me some tips for the placement in the TCS.

0 Answers   TCS,


Is c language still used?

0 Answers  


Explain what is the difference between text files and binary files?

0 Answers  


What is 'bus error'?

0 Answers  


Categories