Consider the following C program carefully. What will be printed on the screen when this program is compiled and executed?
#include <stdio.h>
void counter(void) {
static int calls = 0;
calls = calls + 2;
printf("%d ", calls);
}
int main() {
counter();
counter();
counter();
return 0;
}2 4 6
2 2 2
0 2 4
6 6 6
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 answerMore c output questions