Skip to content
Question Bank (5 marks) · Q3

Q.Briefly explain the format of simple C program.

Karnataka PUCTextbookLong· 5mImportance★★★★★est
12% · 18/154 Questions
✓ Free question

[!TLDR]

A simple C program = #include directive + main() + { declaration part; statement part; } with a semicolon ending each statement.

The format of a simple C program and the role of each part are:

#include <stdio.h>      /* preprocessor directive - links the standard I/O library */
int main()              /* main function - execution begins here */
{                       /* opening brace - start of the function body */
    int a, b, sum;      /* declaration part - declare all variables used */

    a = 10;             /* statement part */
    b = 20;             /* - input / processing statements */
    sum = a + b;
    printf("Sum = %d\n", sum);   /* output statement */

    return 0;           /* returns control to the operating system */
}                       /* closing brace - end of the function body */

Explanation of the parts:

  1. #include <stdio.h> - a preprocessor directive that brings in the standard input/output functions such as printf() and scanf().
  2. main() - the function from which execution always begins; a program must have exactly one main().
  3. Braces { } - enclose the body of the function.
  4. Declaration part - names and types of the variables are declared at the top of the body.
  5. Statement part - the executable statements (input, processing and output), each terminated by a semicolon.
  6. return 0; - hands control back to the operating system.

Expected output:

Sum = 30

[!ANSWER]

A simple C program consists of a #include directive, the main() function, and the body in braces containing a declaration part and a statement part, with execution beginning at main() and every statement ending in a semicolon.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.