GATE Computer Science (CS) 2017 Shift 1 Solved Paper

© examsiri.com
Question : 65 of 65
 
Marks: +1, -0
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;
}
int main() {
static int x= 0;
int i=5;
for(; i > 0; i--) {
x = x + total(i);
}
printf("%d\n", x);
}

  • Your Answer:
Go to Question: