edited by
7,882 views
8 votes
8 votes

What is the output of the following C program?

#include<stdio.h>    
void main(void){
    int shifty;
    shifty=0570;
    shifty=shifty>>4;
    shifty=shifty<<6;
    printf("The value  of shifty is %o \n",shifty);  
}
  1. The value of shifty is 15c0
  2. The value of shifty is 4300
  3. The value of shifty is 5700
  4. The value of shifty is 2700
edited by

7 Answers

0 votes
0 votes
D) 2700
0 votes
0 votes
int shifty;
    shifty=0570;

If an integer constant begins with 0x or 0X, it is hexadecimal. If it begins with the digit 0, it is octal. Otherwise, it is assumed to be decimal.

(https://docs.microsoft.com/en-us/cpp/c-language/c-integer-constants)


shifty=shifty>>4;
 
>> means Right Shift means "divide by 2"

 shifty=shifty<<6;
 
<< means Left Shift means "multiply by 2"
 
Option D
Answer:

Related questions

6 votes
6 votes
3 answers
1
Sourabh Kumar asked Jun 22, 2016
5,554 views
How many lines of output does the following C code produce?#include<stdio.h float i=2.0; float j=1.0; float sum = 0.0; main() { while (i/j 0.001) { j+=j; sum=sum+(i/j); ...
2 votes
2 votes
4 answers
2
jenny101 asked Jun 25, 2016
4,887 views
The following three 'C' language statements is equivalent to which single statement?y=y+1; z=x+y; x=x+1z = x + y + 2;z = (x++) + (++y);z = (x++) + (y++);z = (x++) + (++y)...
7 votes
7 votes
9 answers
3
pooja14 asked Jun 22, 2016
8,031 views
What is the output of the following C program? #include<stdio.h #define SQR(x) (x*x) int main() { int a; int b=4; a=SQR(b+2); printf("%d\n",a); return 0; }14361820
3 votes
3 votes
2 answers
4
ajit asked Sep 23, 2015
5,115 views
Which of the following is true with respect to Reference?A reference can never be NULLA reference needs an explicit dereferencing mechanismA reference can be reassigned a...