Bird
0
0

Identify the error in this C program:

medium📝 Debug Q7 of 15
C - Basics and Execution Environment
Identify the error in this C program:
#include <stdio.h>
int main() {
    int num = 20;
    printf("%d", num)
    return 0;
}
AMissing semicolon after printf statement
BIncorrect format specifier in printf
CVariable 'num' not declared
DMissing return type for main
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax line by line

    The printf statement lacks a semicolon at the end.
  2. Step 2: Confirm other parts

    Variable declaration and format specifier are correct; main has return type.
  3. Final Answer:

    Missing semicolon after printf statement -> Option A
  4. Quick Check:

    Every statement must end with a semicolon [OK]
Quick Trick: Always end statements with semicolon [OK]
Common Mistakes:
  • Omitting semicolons after statements
  • Confusing format specifiers
  • Forgetting variable declarations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes