main()
{
int a=5;
printf(?%d,%d,%d\n?,a,a< <2,a>>2);
}
Answer: 5,20,1 please explain this code in detail

Answer Posted / neha tibrewal ritm jaipur

firstly value of a is printed. value of a=5, so 5 is printed.
Now, a<<2 means 5<<2 i.e 5 is left shifted by 2.
in binary 5= 101
101<<2= 10100 and decimal value of 10100=20.
so, a<<2=20.
again, a>>2 means 5>>2 i.e 5 is right shifted by 2.
101>>2= 001 and decimal value of 1=1.
so, a>>2=1.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c pass by value or reference?

587


When can you use a pointer with a function?

557


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1895


What are the advantages of using new operator as compared to the function malloc ()?

746


Explain what is the purpose of "extern" keyword in a function declaration?

613






What is difference between main and void main?

617


What is structure in c definition?

564


What is a good data structure to use for storing lines of text?

584


What is the meaning of c in c language?

588


What is 1d array in c?

592


What are the data types present in c?

617


How can I find the modification date of a file?

691


What is the use of a conditional inclusion statement in C?

594


What is the -> in c?

573


What is the difference between the expression “++a” and “a++”?

642