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

How do you say “good morning class today I will be talking about my dream car” en español
i need this asap so ye
Help I am Not sure how to answer this Math Question Use the graphs to identify the following: axis of symmetry, x-intercept(s), y-intercept, & vertex.
.............................
Please explain what is a Energy is
Ty has $30 gift card for digital purchases on his phone. He wants to buy some games and songs. Each game (x) cost $3 and each song (y) costs $1.50. Ty wants to
The population of LA is growing at a rate of 5% per year. In 2010, the population was 500,000. What would be the predicted current population?
Will Mark brainliest fro correct answer!!!! Please answer in the picture chemistry
Please help me solve this problem
Wat are two problems associated with public provision of goods and services?