Computer Programming C: UNIT I: Introduction to C

Structure of a 'C' Program

Structure of a 'C' Program

A 'C' program may contain one or more sections given below.

STRUCTURE OF A 'C' PROGRAM

 

1. STRUCTURE OF A 'C' PROGRAM

Before going to discuss any specific features of 'C' language, we shall look at the structure of a 'C' language program. A 'C' program may contain one or more sections given below.


i) Documentation section: It consists of a set of comment lines used to specify the name of program, the author and other details etc.,

ii) Comments: Comments are very helpful in identifying the program features and underlying logic of the program. The lines beginning with '/*' and ending with '*/' are known as comment lines. These are not executable, the compiler is ignored any thing in between /* and */.

iii) Preprocessor section: It is used to link system library files, for defining the macros and for defining the conditional inclusion.

Eg: #include<stdio.h>, #define A 10, #if def, #endif... etc.

iv) Global Declaration Section: The variables that are used in more than one function throughout the program are called global variables and declared outside of all the function i.e., before main(). Every 'C' program must have one main() function, which specify the starting of 'C' program.

The following figure illustrates the various elements of 'C' program.


The main() function consists the following two parts.

v) Declaration part: This part is used to declare all the variables that are used in the executable part of the program and these are called local variables.

vi) Executable part: It contains at least one valid 'C' statement. The execution of a program begins with opening brace '{' and ends with closing brace '}'. The closing brace of the main function is the logical end of the program.

NOTE: All the statements in the program end with a semicolon except conditional and control statements.

 

2. PROGRAMMING RULES

The following rules should be followed while writing a 'C' program.

i) All statements in 'C' program should be written in lower case letters. Upper case letters are only used for symbolic constants.

ii) Blank spaces may be inserted between the words. It is not used while declaring a variable, keyword, constant and function.

iii) The program statement can be written anywhere between the two braces following the declaration part.

iv) The user can also write one or more statements in one line separating them with a semicolon (;).

 

Computer Programming C: UNIT I: Introduction to C : Tag: Computer Science : - Structure of a 'C' Program


Computer Programming C: UNIT I: Introduction to C



Under Subject


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation



Related Subjects


English Essentials I

EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


தமிழர் மரபு - Heritage of Tamils

UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Calculus

MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I

PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Chemistry I

CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Makerspace

ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming Python

CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Fundamentals of Electrical and Electronics Engineering

EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Mechanical Engineering

ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Civil Engineering

CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing

CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I Laboratory

PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Applied Chemistry I Laboratory

CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming Python Laboratory

CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electronics and Electrical Engineering

EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing - Laboratory

CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation