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 was Edgar Allan Poe’s main purpose in writing "Annabel Lee”
how many days sun rises in a year​
The resolution of a story happens when
In what ways were monasteries very helpful during the medieval times?
What was the impact of the slave trade
Select all the correct answers. Which two themes are found in Susan Glaspell's "A Jury of Her Peers"?
When you multiply a function by -1, what is the effect on its graph?
What of b make y = 2x plus b the same as y=2x? What does that value mean? Pls answer:)
Although TV remains a core piece of its overall marketing offering, HSN today looks at TV as one of many different ways for the company to interact with custome
If it requires 38.5 milliliters of 0.85 molar nitric acid to neutralize 20.0 milliliters of barium hydroxide, solve for the molarity of barium hydroxide. Show a