Skip to main content

Three questions and one program

I must be missing coding. So let me write few lines of code and you tell me the output.

1)

int a = 10;
if(a&1)
   cout<<"Hello";
else
   cout<<"hi";
2)
for(int i=2;i<20;i++)
   if(i&(i-1)==0)
     cout<<i<<" ";
3)
   int i =10;
   cout<<(i<<3)<<" ";
   cout<<(i>>3)<<" ";

Please do not open another window and go to online compilers. 

And as I struggled a bit for this, let us see how fast you can come up with the solution.  

Write a program to read two fractions and find their sum. 

No, do not give me the answer in decimal. The answer should be in the form of fraction. 


Comments