Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2017 Set 1
Questions

Q55

NAT2 marksProgrammingMedium

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(; i>0; i--) {
        x = x + total(i);
    }
    printf("%d\n", x);
}
Sign in to save attempts.

The solution is hidden while you attempt this question. It opens once you check or show the answer.