Computer Science, asked by A1m4e6y4, 1 month ago

What will be the output of the following program ?...(Answer is 9, but how)
#include <stdio.h>
void main()
{
int a = 36, b = 9;
printf("%d", a >> a / b - 2);
}

Answers

Answered by rudransh8th33
1

because a is two time smaler then It that will remain 2 and 9-2 then +2

Answered by adventureisland
0

As a result, 36>>2, which is written as 36/4 ⇒ 9 which is written as 1001 in binary form.

Right shift operator :

  • Takes two integers, right shifts all bits of the first operand, and the number of places to shift is determined by the second operand. To put it another way, right shifting an integer "x" with an integer "y" indicated as (x>>y) is the same as dividing x by 2y.
  • Here, a=36, b=9 which is equal to 100100 & 1001 in binary form.
  • When "a is right-shifted by a/b-2,"[ i.e. a/b-2 ⇒ 2 ], As a result, 36>>2, which is written as 36/(2^2).
  • So, 36/4 ⇒ 9 which is written as 1001 in binary form.

Similar questions