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

In Soccer, how many points is each goal worth?
HELP! i need this. its LATE!
3x + 8 = 2 (6x-11) - 5x
a sandwich shop offers a meal which consists of a sandwich and a dessert. ths table shows the options the customers have for their meal. a customer chose turkey
Si le aplicas calor a un cubo de hielo que ¿ocurre con sus partículas?
In Soccer, how many points is each goal worth?
True or False – The British colonized Africa primarily in the northwest region, and the French colonized the south. Question 4 options: a) True b) False
A pool manager balances the pH level of a pool. The price of a bucket of chlorine tablets is $90, and the price of a pH test kit is $11. The manager uses a coup
8-OHydroxy-deoxygenase Measure: A) Indicates the rate of glycolysis B) Measures oxidative damage to DNA C) Reflects mitochondrial ATP production D) Represents p
PLEASE HELPPPPP WILL GIVE BRAINLIEST!!