Operating-Systems
December 8, 2023Question 8139 – Programming
December 8, 2023Question 7951 – Programming
The output of executing the following C program is __________.
#include<stdio.h>
int total (int v) {
static int count=0;
while(v) {
count += v&1;
v ≫= 1;
}
return count;
}
void main() {
static int x = 0;
int i = 5;
for(; 1> 0; i--) {
x = x + total(i);
}
printf("%d\n", x);
}
Correct Answer: A
Question 14 Explanation:
Arithmetic operators have least priority in this case, as count+=v & 1, we first compute v& 1 and then adds to count variable.




23
24
25
26
