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

1.666667 as a fraction
Select the fraction that is equivalent to 0.0368. A.368 over 10,000 B.368 over 1,000 C.68 over 1,000 D. 10,000 over 368
Evaluate the expression when r = 8.2 and s = –3.7. r – 2s a. –22.94 b. 0.8 c. 4.5 d. 15.6
Hi,Can some one tell me how to solve this problem √-27 (step by step please)
Being rejected by a peer group can negatively influence one's self-esteem.
A synonym is a word that's A. similar in meaning. B. defined in a thesaurus. C. opposite in meaning. D. pronounced the same.
A well tested explanation for a wide range of observation or experimental results is called a scientific
what is the main idea of the paragraph. have yo ever wondered how images find there ways onto televisions screen. some tv shows are delivered to homes thro
How does the width of a rectangle change if the length increases but the area remains 300square feet
howcto write 9,000,009 in word form