Bird
0
0

What will be the output of this C program?

medium📝 Predict Output Q13 of 15
C - Basics and Execution Environment
What will be the output of this C program?
#include <stdio.h>
#include "myheader.h"

int main() {
    printMessage();
    return 0;
}

Assuming myheader.h contains:
void printMessage() {
    printf("Hello from header!\n");
}
ANo output
BCompilation error: function not declared
CRuntime error
DHello from header!
Step-by-Step Solution
Solution:
  1. Step 1: Understand #include "myheader.h" effect

    The content of myheader.h is inserted, so printMessage() is defined before main.
  2. Step 2: Check function call and output

    printMessage() prints "Hello from header!\n", so the program outputs that line.
  3. Final Answer:

    Hello from header! -> Option D
  4. Quick Check:

    Included function runs and prints message [OK]
Quick Trick: Including header inserts code, so functions are available [OK]
Common Mistakes:
  • Assuming function is undeclared without prototype
  • Thinking header files can't contain function definitions
  • Confusing compile and runtime errors
  • Ignoring the newline in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes