Computer Science, asked by preetideou, 4 months ago

1.Write a c-programing a right shift and left shift of a shirt signed and unsigned numbers by accepting positive and negative numbers as inputs from the user.Explain the behaviour of the output.​

Answers

Answered by nishanth50141
1

Answer:

Right and Left shift operators are Bitwise Binary Operators operate on Individual Bits of their Integer Operands. On Linux Machine, Logical and Arithmetic Right and Left Shifts on Unsigned Integer values are same but Arithmetic Right Shift on signed integer values are implementation dependent.

explain:

/* rshift_negval.c -- What happens on right arithmetic shift on -ve int */

#include <stdio.h>

int main(void)

{

int x = -1000, y, nbits;

printf("By what no of bits u wanna right shift on signed integer, "

"enter no of bits...\n");

puts("Non integer value terminates the program.");

while (scanf("%d", &nbits) == 1) {

y = x >> nbits;

printf("The value of x in y = x >> %d is %d and y is %d\n",

nbits, x, y);

}

printf("Program Terminated! Good Bye!\n");

return 0;

-THANK YOU

FOLLOW ME

Similar questions