SlideShare a Scribd company logo
Structure of the C Program
The basic structure of a C program is divided into 6 parts which makes it easy to read,
modify, document, and understand in a particular format.
1. Documentation
2. Preprocessor Section / Link Section
3. Definition Section
4. Global Declaration
5. Main() Function Section
6. Sub Programs Section
1. Documentation section: This section consists of the description of the program, the
name of the program, and the creation date and time of the program. It is specified at
the start of the program in the form of comments. Documentation can be represented
as:
// description, name of the program, author date and time of creation
Or
/* description, name of the program, author date and time of creation */
2. Preprocessor Section: All the header files of the program will be declared in the
preprocessor section of the program. Header files help us to link functions from
System Library. Example
#include<stdio.h>
#include<math.h>
3. Definition Section: The #define preprocessor is used to create a constant throughout
the program. Whenever this name is encountered by the compiler, it is replaced by the
actual piece of defined code. This section defines all symbolic constants.
#define pi 3.14
4. Global Declaration: The global declaration section contains global variables,
function declaration, and static variables. Variables and functions which are declared
in this scope can be used anywhere in the program.
int x= 18;
5. main() program Section: Every C program must have a main function. The main()
function of the program is written in this section. Operations like declaration and
execution are performed inside the curly braces of the main program. The return type
of the main() function can be int as well as void too. void() main tells the compiler
that the program will not return any value. The int main() tells the compiler that the
program will return an integer value.
void main( ) or int main( )
6. Sub Programs: User-defined functions are called in this section of the program. The
control of the program is shifted to the called function whenever they are called from
the main or outside the main() function. These are specified as per the requirements of
the programmer.
int sum(int x, int y)
{
return x+y;
}
Example
/ Documentation
/*
file: sum.c
author: M.Sc Students
description: program to find sum.
/
// Link
#include <stdio.h>
// Definition
#define X 20
// Global Declaration
int sum(int y);
// Main() Function
int main(void)
{
int y = 55;
printf("Sum: %d", sum(y));
return 0;
}
// Subprogram
int sum(int y)
{
return y + X;
}

More Related Content

PPTX
CS304PC:Computer Organization and Architecture Session 28 Direct memory acces...
PDF
dbms 1.pdf
PPTX
Fundamentals of database system - Database System Concepts and Architecture
PPT
Computer Oragnization Flipflops
PDF
15CS32 ADE Module 3
PDF
DELD Unit IV ring and twisted ring counter
PDF
File implementation
PDF
Digital Counter Design
CS304PC:Computer Organization and Architecture Session 28 Direct memory acces...
dbms 1.pdf
Fundamentals of database system - Database System Concepts and Architecture
Computer Oragnization Flipflops
15CS32 ADE Module 3
DELD Unit IV ring and twisted ring counter
File implementation
Digital Counter Design

Similar to Structure of the C Program.docx (20)

PPTX
PPs16.pptx
PDF
C PROGRAMMING p-2.pdf
PPTX
C Programming: Basic Structure of C Program
DOC
Basic construction of c
PPTX
C++ Constructs.pptx
PPTX
Overview of C Mrs Sowmya Jyothi
PDF
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
PDF
C programming course material
DOCX
Basic structure of c programming
DOCX
Basic structure of c programming
PPT
OVERVIEW OF ‘C’ PROGRAM
PDF
Data structure week 1
PDF
Introduction To C++ programming and its basic concepts
PDF
Book management system
PDF
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
PPTX
Presentation on Function in C Programming
PPTX
Lecture_5_-_Functions_in_C_Detailed.pptx
PDF
Introduction To Programming With C 1st Edition Nhce
PPTX
C functions by ranjan call by value and reference.pptx
PDF
Chapter 13.1.4
PPs16.pptx
C PROGRAMMING p-2.pdf
C Programming: Basic Structure of C Program
Basic construction of c
C++ Constructs.pptx
Overview of C Mrs Sowmya Jyothi
Module 1_Chapter 2_PPT (1)sasaddsdsds.pdf
C programming course material
Basic structure of c programming
Basic structure of c programming
OVERVIEW OF ‘C’ PROGRAM
Data structure week 1
Introduction To C++ programming and its basic concepts
Book management system
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
Presentation on Function in C Programming
Lecture_5_-_Functions_in_C_Detailed.pptx
Introduction To Programming With C 1st Edition Nhce
C functions by ranjan call by value and reference.pptx
Chapter 13.1.4
Ad

Recently uploaded (20)

PPTX
Internet of Things (IOT) - A guide to understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
Mechanical Engineering MATERIALS Selection
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Artificial Intelligence
PDF
Well-logging-methods_new................
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
composite construction of structures.pdf
PDF
Digital Logic Computer Design lecture notes
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
573137875-Attendance-Management-System-original
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Internet of Things (IOT) - A guide to understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Operating System & Kernel Study Guide-1 - converted.pdf
Foundation to blockchain - A guide to Blockchain Tech
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mechanical Engineering MATERIALS Selection
CH1 Production IntroductoryConcepts.pptx
Artificial Intelligence
Well-logging-methods_new................
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
composite construction of structures.pdf
Digital Logic Computer Design lecture notes
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
573137875-Attendance-Management-System-original
CYBER-CRIMES AND SECURITY A guide to understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT 4 Total Quality Management .pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Ad

Structure of the C Program.docx

  • 1. Structure of the C Program The basic structure of a C program is divided into 6 parts which makes it easy to read, modify, document, and understand in a particular format. 1. Documentation 2. Preprocessor Section / Link Section 3. Definition Section 4. Global Declaration 5. Main() Function Section 6. Sub Programs Section 1. Documentation section: This section consists of the description of the program, the name of the program, and the creation date and time of the program. It is specified at the start of the program in the form of comments. Documentation can be represented as: // description, name of the program, author date and time of creation Or /* description, name of the program, author date and time of creation */ 2. Preprocessor Section: All the header files of the program will be declared in the preprocessor section of the program. Header files help us to link functions from System Library. Example #include<stdio.h> #include<math.h> 3. Definition Section: The #define preprocessor is used to create a constant throughout the program. Whenever this name is encountered by the compiler, it is replaced by the actual piece of defined code. This section defines all symbolic constants. #define pi 3.14 4. Global Declaration: The global declaration section contains global variables, function declaration, and static variables. Variables and functions which are declared in this scope can be used anywhere in the program. int x= 18; 5. main() program Section: Every C program must have a main function. The main() function of the program is written in this section. Operations like declaration and execution are performed inside the curly braces of the main program. The return type of the main() function can be int as well as void too. void() main tells the compiler that the program will not return any value. The int main() tells the compiler that the program will return an integer value. void main( ) or int main( ) 6. Sub Programs: User-defined functions are called in this section of the program. The control of the program is shifted to the called function whenever they are called from the main or outside the main() function. These are specified as per the requirements of the programmer. int sum(int x, int y) { return x+y; } Example / Documentation
  • 2. /* file: sum.c author: M.Sc Students description: program to find sum. / // Link #include <stdio.h> // Definition #define X 20 // Global Declaration int sum(int y); // Main() Function int main(void) { int y = 55; printf("Sum: %d", sum(y)); return 0; } // Subprogram int sum(int y) { return y + X; }