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

In “Nolan Bushnell,” which of the following descriptions best reflects how Bushnell’s first computer game was initially received? A: It was moderately received,
4 and 3 20ths in simplest form
Why were posters necessary to the U.S war effort
Which country was the first to usher in democracy?
In desperate need of help with long division with variables and exponents!!!
is it true that the unltimate sorce of energy of all living things is the leaf?
Solve for x: 4 =(–8)+ 3x
How does Homer foreshadow Odysseus’s pride during the games in Scheria?
About 43% of blood consists of red blood cells. True False
Select Noun Phrase if the underlined group of words is a noun phrase. Select Not a Noun Phrase if the underlined group of words is not a noun phrase. Sentence