Computer Science, asked by nid2412, 11 months ago


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);

Answers

Answered by ani99ket
1

Answer:

2700

Explanation:

>> << are bitwise right shift and bitwise left shift.

Therefore they operate on bit values.

also shifty is an octal number because it begins with a 0 (12 -decimal, 012 - octal, 0x12 - hexadecimal)

lets convert 0570 to decimal  = 5 X 8² + 7 X 8 + 0 X 1 = 320 + 56 = 376.

lets convert 376 to binary = 1 X 256 + 0 X 128 + 1 X 64 + 1 X 32 + 1 X 16 + 1 X 8 + 0 X 4 + 0 X 2 + 0 X 1 = 101111000.

for >> 4 bits will be 000010111(23)

for <<6 bits will be 000010111000000 ( 23 X 2^6 = 23 X 64 = 1472)

for octals print divide binary into triads .. 000 010 111 000 000 000 = 02700

Similar questions