C is a procedural programming language initially developed by Dennis Ritchie at Bell Laboratories in 1972. It was developed along with the UNIX operating system. The syntax of many programming languages including Java, PHP, JavaScript is primarily based on the C language.
Features of C Programming Language
The growing popularity of C is most likely due to its many desirable characteristics. The following are the important features of the C programming language.
- Robust language – Well suitable for writing any complex programs.
- Fast and efficient programs – Becuase of variety of data types and operators.
- Rich set of inbuilt functions.
- Highly portable.
- Well suited for structured programming.
- Ability to extend itself.
Basic Structure of C Programs
A C program can be thought of as a collection of blocks known as functions. A function can be defined as a subroutine that contains one or more statements that perform a specific task. A C program may contain one or more sections as follows.
The document section of the program is made up of a set of comment lines containing details like the name of the program, author, etc.
The link section contains instructions to the compiler on how to link functions from the system library.
All symbolic constants are defined in the definition section.
Variables that are used in multiple functions are known as global variables. These variables are declared in the global variables section.
Every C program should have a main() function section. It is a special function used by the C to tell the computer where the program starts. The main() section is divided into two parts: the declaration part and the executable part. The declaration section declares all variables. The executable section contains at least one statement. These two parts must be written inside the opening and closing braces. All statements in the declaration and executable sections are followed by a semicolon (;).
All user-defined functions that are called in the main function are written in the subprogram section.
Except for the main function section, all sections may be skipped when they are not required.
Hello World Program in C
The following program in C prints the message “Hello World !” on the screen as below:
#include<stdio.h> main() { printf("Hello World!"); }
Executing a C Program
Executing a program written in C involves the following steps:
- Creating the program.
- Compiling the program.
- Linking the program with functions that are needed from the C library.
- Executing the program.