Open In App
Related Articles

ISRO | ISRO CS 2014 | Question 32

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
Write the output of the following C program
#include <stdio.h>
  
  int main (void)
  {
  int shifty;
  shifty = 0570;
  shifty = shifty >>4;
  shifty = shifty <<6;
  printf("the value of shifty is %o",shifty);
  }

                    
(A) the value of shifty is 15c0 (B) the value of shifty is 4300 (C) the value of shifty is 5700 (D) the value of shifty is 2700

Answer: (D)

Explanation: Given, shifty = 0570; here shifty is a octal number as it starts with 0.
(0570)8 = (000 101 111 000)2
Right shift by 4 places:
shifty = shifty >>4;
shifty = (000 000 010 111)2
Left shift by 6 places:
shifty = shifty <<6
shifty = (010 111 000 000)2
       = (2700)8
So, option (D) is correct.

Quiz of this Question

Last Updated : 16 May, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads