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 idea is Chisholm emphasizing by repeating the term good guys?
In 1950, the NAACP focused its legal efforts on which of the following items?
define the quadratic formula with numbers a=2 b=8 c=12
How do you answer this?
What are the domain and range of the function?
A swimming pool has to be drained for maintenance. The pool is shaped like a cylinder with a diameter of 10 m and a depth of 1.7 m. Suppose water is pumped out
First to answer with work shown gets Brainliest
1. Describe the formation of the four types of fronts and the weather associated with each 2. How does the burning fossil fuels influence global temperature. Ho
People who wanted to work out the south’s differences with the north
which of tht following is an informal economic institution