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

A director position in research would normally require at least a ____.
How to determine if a differential equation is linear or nonlinear?
How many joules of energy are necessary to heat a sample of water with a mass of 46.0 grams from 0.0 Celsius to 100.0 Celsius? (Use 4.184 J/g Celsius for the sp
How to subtract a negative from a positive number?
Kendall knows that a 45-ounce pitcher can hold enough lemonade for 6 people. At this rate, how many ounces of lemonade will Kendall need to serve 26 people?
When looking at the map, what can you tell about the colonial european settlements?
When is income considered to be earned by an​ accrual-basis taxpayer?
What would happen if you put a mixture of proteins and starch in a solution containing trypsin
Graph the linear function f(x) =3x+2 and find the maximum on the interval [-1,1]
Please solve for x (X+4)/x=45