dragonffkc8757 dragonffkc8757
  • 02-05-2021
  • Computers and Technology
contestada

Write a C program that right shifts an integer variable 4 bits. The program should print the integer in bits before and after the shift operation. Does your system place 0s or 1s in the vacated bits?

Respuesta :

AbsorbingMan AbsorbingMan
  • 03-05-2021

Solution :

#include<[tex]$\text{stdio.h}$[/tex]>

#include<conio.h>

void dec_bin(int number) {

[tex]$\text{int x, y}$[/tex];

x = y = 0;

for(y = 15; y >= 0; y--) {

x = number / (1 << y);

number = number - x * (1 << y);

printf("%d", x);

}

printf("\n");

}

int main()

{

int k;

printf("Enter No u wanted to right shift by 4 : ");

scanf("%d",&k);

dec_bin(k);

k = k>>4; // right shift here.

dec_bin(k);

getch();

return 0;

}

Answer Link

Otras preguntas

Please help with this as soon as possible
Ashley needs a 4.6 yards of chain to hang some flower baskets the chain is sold by meter how many meters does Ashley need
Using the drop-down menus, identify the structures common to all cells. Label A Label B Label C Label D
oppression against people who make less money is called? A. classism B. anti-semitism C. racism D. sexism
Which word best describes John Smith? (1 point) Governor Merchant Minister Traitor
If m∠W = 105° and m∠Y = 75°, then m∠X
WHO HERE HAS A GOOD HEART AND WOULD LOVE TO ASSIST A FELLOW BRAINLY MEMBER IN NEED OR ANSWERS? PLZ I NEED THIS COMPLETED ASAP!!!!!!10 POINTS English Honors Assi
Arrange the following in order of increasing density: B, Li, Rb, F
Which two terms best describe the gravitational pull?
Briefly describe the Blood less Revolution?​