Skip to content
Question Bank (5 marks) · Q2

Q.Write ten basic structure of C programming (overview).

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

[!TLDR]

An overview of a C program's structure covers documentation, preprocessor and definition sections, global declarations, main() with its braces, declaration and statement parts, subprograms and the return statement.

The overall structure of a C program can be described through its basic parts, written in the following order:

  1. Documentation section - opening comments giving the title, author and purpose.
  2. Preprocessor / link section - #include directives that attach the required header files.
  3. Definition section - #define directives that create symbolic constants and macros.
  4. Global declaration section - variables and function prototypes shared by all functions.
  5. main() function header - main(), where execution begins.
  6. Braces { } - mark the start and end of the function body.
  7. Declaration part - local variables declared at the top of the body.
  8. Executable statement part - the input, processing and output statements, each ending with a semicolon.
  9. Subprogram section - user-defined functions written before or after main().
  10. return statement - returns a value/control to the operating system.

A general skeleton:

/* 1. documentation */
#include <stdio.h>      /* 2. preprocessor */
#define PI 3.14         /* 3. definition */
int g;                  /* 4. global declaration */
int main()              /* 5. main header */
{                       /* 6. opening brace */
    int a, b;           /* 7. local declaration */
    /* 8. executable statements */
    return 0;           /* 10. return */
}                       /* 6. closing brace */
/* 9. user-defined functions here */

[!ANSWER]

The program is structured as documentation, preprocessor directives, definition section, global declarations, the main() function with its braces, local declarations, executable statements, user-defined functions and a return statement - only main() being compulsory.

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.