Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C please, Thanks Design a program to shift one high bit to the left bit by bi

ID: 3764789 • Letter: I

Question

In C please, Thanks

Design a program to shift one high bit to the left bit by bit until it reaches the position 32 and then shift to the right bit by bit until the first position as shown in the next figure:

1-00000000 600G00GD G0000000 00000001 2 4 8 0000 000 0@00@000 0@00 000 0@00@000 0@00@000 0@000000 000 000 000 00@0 00@0 00@0 000@0@ 10 000@0 1@0 000@i@@0 32-B0060060 6006000 600G0000 0010060 64 00000000 00000000 000000 01000000 1286006006D B0060000 6000000D 1060060E 2566006006D G0060000 60000001 G06006GE 000090 00060109 09069000 2048 = 00000000 00000000 0001 000 00000000 4096 00000000 00000000 00010000 00000000 8192 00000000 00000000 00100000 00000000 16384 00000000 00000000 01000000 00000000 32768 00000000 00000000 10000000 00000000 65536-0900900 00G000109006900 000000g 131072 = 00000000 00000010 00000000 00000000 1024 = 00000000 00000000 000100 00000000 26214400000000 60000100 0000000 000000 524288-0000000 00001000 00000000 0000000g 19485760000000 00010900 00000000 00000000 2097152 0000080 80100000 00000000 00000000 1194301-00000000 1000000 00000000 00000000 8388608-00000000 10000000 00000000 00000000 16777216-00000001 00000000 00000000 00000000 33551132 00000010 00000000 00000000 00000000 67108864-00000100 0000000g 00000000 00000000 13421772800001000 000000G0 00000000 00000000 26 00G0OG00 G0000000 00000000 53687091200100000000G0O00 G0000000 00000000 0737418240100000G0GOO00 G0000000 00000000 14748364810000000 G00000G0 000000GD 00000000 14748364810000000 G00000G0 000000GD 00000000 07374182401000000 0000000 00000000 0000000 53687091200100000 G00000G0 00000000 00000000 26843545600010000 G00000G0 00000000 00000000 13421772800001000 G0000000 00000000 00000000 67108864-00000100 00000000 00000000 00000000 3355443200000010 00000000 00000000 G0000000 1677721600060001 00000000 00000000 G0000000 83886080006000 10000000 00000000 00000000 4194304 0000@000 01 00@000 000 0000 000@00@0 2097152 0000@000 00 100000 000 00@0 000@00@0 1048576 = 0@00@000 000 10000 0 0 000 000@00@0 5242 88 0@00@000 0000 1 000 000 00@0 @00@00@0 262144 = 0000@000 00000100 0,0 000 000@00@0 131072 00000000 00000010 0 0 0000 00000000 65536 00000000 00000001 @@@@0000 00000000 32768 00000000 00000000 1000000 00000000 16384 00000000 00000000 01@@@@00 00000000 8192 00000000 00000000 010000 00000000 4096 00000000 00000000 10000 00000000 2048 = @0000000 00000000 @@001 000 00000000 8435456 00010000 524288 00900080 1024 00000000 00000000 00000100 00000000 8 8188 88aa0 512 00000900 60900900 GD900019 G0009000 256 00000000 60000900 G0000001 0009000 128 = 00000000 00000000 00000000 10000000 64 00000000 00000000 00000000 01000000 32 = 00000000 00000000 00000000 00100000 16-00000000 00900900 00000000 00010000 800000000 00000000 00000000 00001000 400000000 00000000 00000900 00000100 801 20000000 00090000 0000000 0090061 100000000 00000000 00000000 00000001

Explanation / Answer

#include <stdio.h>

void print(int n){
   int i;
   for(i = 1; i < 32 - n; i++){
       printf("0");
   }
   printf("1");
   for(i = 32 - n; i < 31; i++){
       printf("0");
   }  
}
int main(){
   long num = 1, i;
   for(i = 1; i < 32; i++){
       printf("%10ld = ", num);
       print(i);
       printf(" ");
       num <<= 1;
   }
   printf("%10ld = ", num);
   print(i - 1);
   printf(" ");
   for(i = 1; i < 32; i++){
       printf("%10ld = ", num);
       print(32 - i);
       printf(" ");
       num >>= 1;
   }
}