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 a things to built smk sri kurau
A function is _____ a relation.. a. always. b. sometimes. c. never
1. _________ is compared to a turtle. (1 point) Ronald Givens The metro editor Dolly Givens Richard Brautigan 2. The wish is ___________ to the deed. (1 p
\"Give the nuclear symbol for the isotope of gallium, Ga, that contains 40 neutrons per atom.\". .
A function is _____ a relation.. a. always. b. sometimes. c. never
Which of the following is an exothermic reaction? A. dissolving ammonium nitrate in water to cool the water B. condensation C. melting ice D.
1. Tennis is probably the most popular sport played with a racquet. Which of the following lesser known sports is played with a racquet as well? (1 point) La
How to add or subtract radians? For example: pi/3 - pi/6 ?
according to the study unit addition is defined as
The acceleration of gravity is a constant equal to _______ meters per second squared. A. 10.2 B. 9.8 C. 8.4 D. 7.6