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

Translate to an algebraic statement. "The quotient of twice a number and 7 is 20." ) Solve the equation you translated
PART B:Which quote from the story best supports the answer to PART A
Consider the system of linear equalions. . 2y = x + 10 3y = 3x + 15
NO LINKS AS AN AWNSER Choose all the right answers. Select three options. The structures common to all protozoa are: cilia nucleus cell wall cell membrane chl
please look at image and don't answer if you don't know
The arrow in the photo represents a force. Which force is equal but opposite to the one shown? A. The force of air resistance that acts on the ball B. The force
to meet the requirement for the number of vdss on board, what must be true about pyrotechnic vdss?
Does anyone know Hindi if yes I need help with my homework
As president, Lincoln’s goal was to unify the North and the South. Write a paragraph about how this speech supports that goal. Cite examples from the text. : )
I need help with this