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

what is a browser cookie?
which is the better buy $6 for 3 packages or $5 for 2 packages
which is one major function of the endomembrane system producing and storing energy transporting substances in a cell manufacturing proteins directing the cel
Why does the author likely include the section entitled “Changing Russia”?
which is the better buy $18 and 3 flash drivers or $35 and 5 flash drivers
where is are the cordinants 52,77
Multiply. The question is in the picture.
What is the Wilmot Proviso (1848) and why is it significant? Supports: 1. 2. 3. Thesis Statement:
Ornamentation was not originally intended to _____ . show off a musician's technical skills embellish a repeated passage provide added interest for the listener
What type of conflict is if I stay by gayle Forman? Man vs. _______ Please help will give branliest