ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
static int helper(int x) { return x * 2; }
int main(void) {
    printf("%d", helper(5));
}
  1. A. 10
  2. B. Compile-time error: static functions cannot be called from main
  3. C. 5
  4. D. Linker error: helper has internal linkage and cannot be called

Correct answer: A. 10

static on a FUNCTION (not inside a function body) simply gives it internal linkage, confining its visibility to this translation unit — it does not restrict who within that same file can call it. main() is in the same file, so calling helper(5) is perfectly normal, returning 10.

More C Programming questions

Exams that ask this topic