C (Programming Language)- Characteristics, Phases and Structure of C


‘C-language’ is one of the most popular and modern computer programming language. Because of it’s characteristics ‘C-Language’ became popular. Some of the characteristics of ‘C’ language are mentioned below.

General Characteristics of ‘C’ Language

  • Generality
  • Middle-level language
  • Extensive library functions
  • Efficiency and speed
  • Portability
  • Structured programming

1. Generality

‘C’ language is a general-purpose language and used to write programs varying from simple to complex. Nowadays, C Language is used in developing applications that are effectively used in academic campuses, multinational companies, etc.

2. Middle-Level Language

‘C’ language possesses the capabilities of both low-level languages (example: assembly language) and high-level languages. Therefore, ‘C’language can be used for writing system software (Examples: operating systems, compilers, etc.) and application software (examples: video games, business packages, etc.).

3. Extensive Library Functions

‘C’ language consists of built-in library functions making which makes it a robust language. Any complex program can be easily written using these built-in functions—examples: printf, scanf, etc.

4. Efficiency and Speed

‘C’ Programming language has a rich set of data types and operators, Which makes the language more efficient and faster. The language provides some operators (example: increment and decrement operators) which speed up the execution to a large extent. It also provides user-defined data types (example: structures) through which it can easily manipulate miscellaneous data.

5. Portability

‘C’ language is portable. The programs which is written on one machine can be executed on any other machine with or without doing some minor changes in the program.

6. Structured programming

A ‘C’ program can be defined as a collection of function modules (i.e., performing a task unit) and blocks. It also provides basic control flow statements essential for structured programming (examples: if-else, switch, while, for, etc.).

Developing a ‘C’ Program

A ‘C’ program has to pass through many phases for its successful execution and desired output. The phases or steps required for the successful execution of a C program can be visualized as follows,

Block diagram to represent Phases in C Program
Block diagram to represent Phases in C Program

Editing Phase

The C program is entered into a file (i.e., source code) in the editing phase through a text editor. A text editor is provided by the UNIX Operating System, which can access using the command vi. Modern compiler vendors provide IDEs (Integrated Development Environments) consisting of editor and compilers (Example: Turbo C, Turbo CH, CH, etc.). The file is saved on the disk with an extension of ‘c’ (not mandatory, user can have their own extension). These editors are used in doing correction at later stages of the program. Once the program has been written, it must be translated into machine language (i.e., in the compilation phase).

Compilation Phase

This phase is carried out by a program called a compiler. A compiler is used to convert the source code into the object code (i.e., machine-understandable language). The compilation phase cannot proceed successfully unless the source code is error-free (i.e., no syntactic and semantic errors). The compiler shows a message if it encounters any syntax errors in the source code of the program. Now the error-free source code is converted into object code and stores with an extension’ .obj” in a separate file.

Linking phase

All the files and functions in the program with the object code which under execution is linked using a linker. For example, if a user uses a ‘printf’ function in his/her program, the linker links the user programs object code with the object code of the printf function (available in the ‘stdio.h’ library). Now, the object code is ready for the next phase (i.e., the execution phase).

Execution Phase

The executable object code is loaded into the memory in this phase, and the program execution begins. Even though the compilation phase is successful we can encounter errors in the execution phase. The errors may be runtime errors (example, divided by zero) and logical errors.

General Structure of a ‘C’ Program

‘C’ is a structural programming language. A ‘C’ program is a collection or set of functions collection of statements, which performs a specific task in the program.
‘C’ program in general consists of various sections which can be elaborated as follows, Consider a sample program (printing a line of text on monitor) to get a clear concept of the basic structure of C

Structure of C Program
Structure of C Program

Documentation Section

The readability of the program can be enhanced by using comments, Comments about the program can be provided by the programmer in this section. The comments are included between the delimiters /*’ and ‘*7’. These statements are not executable. Instead, the compiler ignores them. But too many comments should be avoided in the program.
Example: Line 1 /*Program printing a line of text*/

Header Files Section

A ‘C’ program depends on the header files to a great extent. A header files contains the information which is required by the compiler. It calls the library functions that are used in the program which is required during compilation. A header file has an extension of ‘h.’ These files are included in the program using the preprocessor directory ‘#include.’
Example: Line 2 #include This is the header file for the library function printf();

Global Declaration Section

The global variables can be declared in this section. Sometimes in a ‘C’ program, there is a need for declaring a some common variables to all other functions existing in the program, Such variables should be declared in this global declaration section. To deal with such circumstances global variable section is used.

Program Section

The Program section begins with a function called main(). Every ‘C’ program must contain only one main() function. It is the beginning point for program execution. The main function has no parameters or arguments. The Opening brace “{” indicates the beginning of the program and closing brace “}” indicates the completion of the program after the main() function. The main() function consists of declaration and executable statements. The group of statements in main() is executed sequentially.

Example: Line 4, Line 5, Line 6, Line 7, Line 8, Line 9, and Line 10 in the below program.

User-defined Function Section

In C language user can define their own functions which is known as user defined function. These user-defined functions are defined after the main() function. This section is not mandatory in each ‘C’ program.

Refer this example Program

 /* Program printing a line of text*/

#include<stdio.h> /
#include<conio.h> / Header File Section
printf(“Welcome to  latesttechai.com“); Main Program Section
return 0;

Previous Article

What is a Computer?- Classification and anatomy of computer

Next Article
What is DBMS

What is DBMS(Database Management System)-Applications of DBMS