Skip to content
Solved Examples · Example 1

Q.Explain the basic structure of a C program. The textbook views a C program as a group of building blocks called functions and presents the general structure as follows:
Documentation Section  
Link Section  
Definition Section  
Global Declaration Section  
main() Function Section  
{  
    Declaration part  
    Executable part  
}  
Sub program Section  
    Function 1  
    Function 2  
    -    -  
    -    -    (user defined functions)  
    -    -  
    Function n  

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

[!TLDR]

Every C program follows a fixed skeleton whose only compulsory part is the main() function; all other sections are optional but always appear in the same order.

A C program is built from functions, and to write a program we first create the functions and then put them together. The sections of the program, in order, are:

  • Documentation Section: comment lines (giving the program name, author, purpose, date) that improve readability and are ignored by the compiler.
  • Link Section: the preprocessor #include directives that link the program with header/library files such as stdio.h.
  • Definition Section: the #define directives that define symbolic constants and macros.
  • Global Declaration Section: declarations of variables and functions that must be available throughout the program (before main()).
  • main() Function Section: the compulsory function where execution begins. Its body, enclosed in braces { and }, has two parts — a declaration part (declaring the variables used) and an executable part (the statements that perform the task).
  • Sub-program Section: the user-defined functions (Function 1, Function 2 ... Function n) that are called from main() or from one another.

Only the main() function is mandatory; a valid program can contain just main(). The other sections are added as the program needs them. This layout is a standard Karnataka 2nd PUC Electronics C-programming question.

[!ANSWER]

A C program consists of the Documentation, Link, Definition and Global Declaration sections, followed by the mandatory main() function (with its declaration and executable parts) and an optional Sub-program section of user-defined functions; execution always starts at main().

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.