Question 5 of 110Programming Basicsc output

Consider the following C program carefully. What will be printed on the screen when this program is compiled and executed?

#include <stdio.h>
int main() {
    int k = 2, s = 0;
    switch (k) {
        case 1: s += 1;
        case 2: s += 10;
        case 3: s += 100;
            break;
        case 4: s += 1000;
    }
    printf("%d", s);
    return 0;
}

The verified answer and full solution are one login away

Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.

Log in to see the answer
← Q4Q6Attempt the full timed mock

More c output questions