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

Tell me what is null pointer in c?

0 Answers  


regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression

1 Answers   TCS,


what is the difference between #include<> and #include”…”?

5 Answers  


What is the difference between typedef struct and struct?

0 Answers  


What is the use of a static variable in c?

0 Answers  






SRUCTURE PROGRAMMING

3 Answers   CTS, Wipro,


What is a dynamic array in c?

0 Answers  


Does free set pointer to null?

0 Answers  


What is sizeof array in c?

0 Answers  


please explain every phase in the "SDLC" in the dotnet.

0 Answers  


write a program that finds the factorial of a number using recursion?

13 Answers   Infosys, TATA,


#include<stdio.h> #include<conio.h> void main() { clrscr(); int a=0,b=0,c=0; printf("enter value of a,b"); scanf(" %d %d",a,b); c=a+b; printf("sum is %d",c); getch(); }

2 Answers  


Categories