Which of the following would be the value of z for the C program code?
x = 16;
y = 4;
z = x >> y;
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. 1
Explanation
The >> operator is the right-shift operator; x >> y shifts the bits of x to the right by y positions, which for a non-negative x is equivalent to integer division of x by 2^y. Here x = 16 (binary 10000) and y = 4, so z = 16 >> 4 = 16 / 2⁴ = 16 / 16 = 1. So z evaluates to 1.More Programming Languages and Computer Graphics questions
- What will be the output of the following program? #include<stdio.h> int main() { int i; for (i = 0; i++<10; ) printf("%d", i++); return 0; }
- Match the LIST-I with LIST-II. LIST-I LIST-II A. Pivot point I. Reflection B. Fixed point II. Shear C. Mirror image III. Rotation D. Distor…
- The number of pixel columns divided by the number of scan lines that can be displayed by the system, is called
- The above figure shows a triangle at an original position (vertices labelled 2, 1, 3) to the left of the y-axis, and the same triangle, fil…
- What will be the output of the following C programming code:int i, j; for(i=1; i<5; i+=2) for(j=1; j<i; j+=2) printf("%d", j);
- What would be the equivalent pointer expression for referring the array element ar[m][n][0]?