Published by: BhumiRaj Timalsina
Published date: 11 Jan 2022
C is a structured programming language developed by Dennis Ritchie at Bell Laboratories in 1972. Since C is a structured programming language, a program in C language can be divided into small logical and functional modules. C++ language is an expanded version of C.
Characteristics of ‘C’ Language
Now, it had become a widely used professional language because of the following reasons.
It is a reserved word, some meaning is already available to that word and that meaning will be recognized by the compiler.
In ‘C’ programming language total no. of keywords are ‘32’
E.g.:- If, else, while, const, break….
Keywords=32, operators=44, separators=14.
After the above discussion, we can formally assess the structure of a C program. By structure, it is meant that any program can be written in this structure only. Writing a C program in any other structure will hence lead to a Compilation Error.
1) Header Files Inclusion: The first and foremost component is the inclusion of the Header files in a C program.
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. Some of C Header files are given below:
2) Main Method Declaration: The next part of a C program is to declare the main() function. The syntax to declare the main function is:
int main() {}
Variable Declaration: The next part of any C program is the variable declaration. It refers to the variables that are to be used in the function. Please note that in the C program, no variable can be used without being declared. Also in a C program, the variables are to be declared before any operation in the function.
Example:
int main() {
int x;
Body: The body of a function in the C program, refers to the operations that are performed in the functions. It can be anything like manipulations, searching, sorting, printing, etc.
Example:
int main() {
int a;
printf("%d", a);
A loop causes a section of a program to be repeated a certain number of times. The repetition continues while the condition set for it remains true. When the condition becomes false, the loop ends the control is passed to the statement following the loop. A computer is the most suitable machine for performing repetitive tasks, and it can perform a task thousands of times. Every programming language has the feature to instruct to do such repetitive tasks with the help of certain statements. The process of repeatedly executing a collection of statements is called looping. The statements get executed many numbers of times based on the condition. But if the condition is given in such logic that the repetition continues any number of times with no fixed condition to stop looping those statements, then this type of looping is called infinite looping.
A variable in simple terms is a storage place which has some memory allocated to it. Basically, a variable used to store some form of data. Different types of variables require different amounts of memory and have some specific set of operations which can be applied to them. Variables can be changed according to the need of the programmer.
As the name suggests the name constants is given to such variables or values in C programming language which cannot be modified once they are defined. They are fixed values in a program. There can be any types of constants like integer, float, octal, hexadecimal, character constants etc. Every constant has some range. The integers that are too big to fit into an int will be taken as a long. Now there are various ranges that differ from unsigned to signed bits. Under the signed bit, the range of an int varies from -128 to +127 and under the unsigned bit, int varies from 0 to 255.Those values which can't change during the program execution is called constant. Example: A = 10.