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 4/9 - 2/15 in simplest form
A number s is subtracted from seven. When the result is divided by three, the quotient is two. What is the number?
1.If you cross two pea plants that are heterozygous for flower color (Pp), what is the percent chance that the offspring will be white? 2.Round peas (R) are dom
What states made up the upper south?
IF YOU HAVE READ OR WATCHED THE CHRISTMAS CAROL PLEASE ANSWER. Scene 2 1. Who appears to Scrooge? What is required of the visitor? 2. Why is the visitor there?
What is one reason coral reefs are such diverse ecosystems?
What is a instrument that measures precipitation?
According to Montresor, he decides to seek revenge against Fortunato because Fortunato __________. A. attacked him with his fists B. injured him more than a tho
wendy's brother drank 3/10 of the gallon of milk in the fridge. what percent of the milk did he drink.
write each rate as a unit rate. 3 inches of rain in 6 hours