C is a programming language developed at Bell Laboratories, US, in the year 1972 by Dennis Ritchie. C is an extremely popular language because it is simple,efficient and reliable. C is considered to be a middle-level programming language since it has the features of both low level language and high level language. On one hand, C has relatively good programming efficiency, on the other, it has relatively good machine efficiency.
History of C Language :-
Developing a common programming language which can be used to solve different types of problems on various hardware platforms has always been a computer professional's dream. One such attempt was development of a language called Combined Programming Language (CPL) at Cambridge University in 1963. However, it turned out to be too complex, hard to learn and difficult to implement. subsequently, in 1967, a subset of CPL, Basic CPL (BCPL) was developed by Martin Richards incorporating only the essential features of CPL. However, it was also not found to be sufficiently powerful. Around the same time, in 1970, another subset of CPL, a language called B as developed by Ken Thompson at Bell Labs. However, it turned out to be insufficient in general. In 1972, Dennis Ritchie at Bell Labs developed C Language incorporating best features of both BCPL and B languages.
Features of C Language :-
C is often termed as middle level programming language because it combines the power of a high level language along with the flexibility of a low level language. High Level Languages have a number of built-in features and facilities which result in high programming efficiency and productivity. Low level languages, on the other hand are designed to give more efficient programs and better machine efficiency.
C is designed to have a good balance between both the extremes. Programs written in C give relatively high machine efficiency as compare to high level languages. Similarly, C programs provide relatively high programming efficiency as compared to low level languages. Thus C can be used for a range of application with equal ease and efficiency.
Why is C Language Popular :-
Several feather which make C a suitable language to write system programs are as follows :
C is a machine independent and highly portable language.
It is easy to learn, has only 28 keywords.
It has a comprehensive set of operators to tackle business as well as scientific application with ease.
Users can create their own functions and add to C library to perform a variety of tasks.
C language allows manipulation of BITS, BYTES and ADDRESSES.
It has a large library of inbuilt function.
C operates on the same data types as the computer, so the code generated are fast and efficient.
Components of C Language :-
The five main components of C language are :
Character Set
Data Types
Constants
Variables
Keywords
Character Set :-
Any alphabet, digit or special symbol used to represent information is denoted by a characters in C are grouped into four categories.
Letters : A-Z or a-z
Digits : 0, 1, 2, ................,9
Special Symbol : ~ ! @ # $ % ^ & * ( ) _ + = - [ ] { } ; ' : " , . / < > ?
White Space : Blank Space, Horizontal Tab, Carriage Return, New Line and Form Feed.
Data Types :-
The power of a programming language depends among other things on the range of different types of data it can handle. C language is design to handle five primary data types, namely character, integer, float, double and void and several secondary data types like array, pointer, structure, union and enumeration.
Constants :-
A constant is a fixed value entity that does not change. It can be stored at a location in the memory of the computer and can be referenced through that memory address.
Variables :-
A variables is an entity whose value can change during program execution. A variable can be thought of s symbolic representation of address of the memory whose values can change.
Keywords :-
Keywords are those words which have been assigned specific meaning in the context of C language programs. Keywords should not be used as variable names to avoid problems or compile time errors.
A Simple C Language Program :-
/* Program to calculate are of ciricle */
#include<stdio.h>
main()
{
float radius, area;
printf("Enter the radius\n");
scanf("%f", &radius);
area = 3.14 * radius * radius;
prinf("Area = %f\n",area);
}
The first line is a comment that identifies the purpose of the program.
The second line contains a reference to a special file (stdio.h) which contains information that must be included in the program. This file contains the important and normal used I/O function of C language. It is a prepocessor directive that we talked about in the last section.
The third line is a heading for the function main().
The remaining five lines of the program are indented and enclosed within a pair braces.
The first indented line is a variable declaration. It establishes the names radius and area as floating point variable.
The remaining four indented lines are expression statements. The second indented line printf() generates a request. This value is accepted by the system via the third indented line scanf().
The fourth indented line is an assignment statement. This statement causes the area to be calculated from the given value of the radius.
The last indented line printf() causes the calculated value for the area to be displayed on the output screen.
Notice that each individual expression statement ends with semicolor.