What is the output of the following C program?
#include<stdio.h>
int main (
{
int a = 5;
a
= a << a >> a = 1;
printf ("%d", a);
return 0;
}
Answers
Answered by
3
Answer:
If both operands are different, output is 1. 7) What is the output of Left Shift Operator << on (00011000<<2).? Explanation: Left Shift Operator << shifts bits on the left side and fills Zeroes on the Right end.
Answered by
0
Answer:
The output of the following C program is 5.
Explanation:
The given code block is:
#include<stdio.h>
int main (
{
int a = 5;
a = a << a >> a = 1;
printf ("%d", a);
return 0;
}
Let's understand the code above:
- First, we have integer variable a that is initialized with 5.
- In the second line, we performing the right shift and left shift on a variable.
- The left shift operator is used to moving the bits to the left-hand side while the right shift performs shifting on right-hand side.
- Since we using both so the resultant is the same number that we entered initially.
- And in the last line, when we print the value of a it will be 5 only.
#SPJ3
Similar questions