Sunday, 16 April 2017

C language fundamental

Fundamental of C Language

In simple term, a language is a medium of communication,people use languages (Hindi, English, Tamil etc) to communicate with each other. In computing world, a computer language is a medium to communicate with computers. Computer languages are used to write instructions to tell  computer to perform some action/operation. Collection of instructions is called program.

There are many computer languages exists now a days, c language is one of them.Every language has a character set (e.g. English has character/alphabet A to Z), a set of words (e.g. English language has words, we have seen in dictionary) and a set of rules (e.g. English language has grammar, which is actually the set of rules). C language too has a set of character which is known as C Character Set, it include following symbols

A-Z, a-z, 0-9,  . (full stop),  , (comma) : (colon), ; (semi colon)  ‘ (single quote), ” (double quote), #  (hash), %  (percent), & (ampersand) ! (exclamatory sign),  _ (underscore), { (open curly brace), } (close curly brace), [ (open square bracket), ] (close square bracket),  ( (normal open bracket) , ) (normal close bracket),  | (vertical bar), +  (addition) , –  (minus), / (back slash),  * (astrick), = (equal) , \ (forward slash)

Every instruction or syntax of c language is made up of these symbols only. There are few words which are made up of these symbols and known as keywords or reserve words. These words has predefined meaning for c language and are designed to perform a particular task, a programmer can not use these key words for any task other than they are defined for. These are as follows

auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct double
Above table shows the reserve words or keywords of c language, We cant use these keywords for any purpose other than they are declared for.

Programs are the set of instructions, and instructions are written to process the data. Data are the collection of facts and figures, these facts and figures could be of alphabets e.g. Name of a person, or numerical (either integer or floating point) e.g. Number of copies of books in a library are of Integer type, while salary of a person is of floating point type. To process the facts and figures (data), we need to store them in variables e.g. the basic salary of an employee would be store in a variable “B_Salary”, so that we can process this basic salary to calculate the total salary by adding 10%  TA/DA in it by the formula

Total_Salary= B_Salary +  (Basic_Salary  *  10 / 100);

here the Total_Salary and B_Salary are the variables which are used to store the basic salary and total salary of an employee (which is numerical in nature). So variables are the program elements which are used to store data values and this data value can be either alphabetical or numerical depending on the type of data.

There are three fundamental data type in C language, these are integer, character and float, for which three reserve words are used i.e. int, char and float. These keywords are used to declare the variable. e.g. we have 3 instructions as
int a;
float b;
char c;

The above instruction will declare 3 variable a,b and c from which a is of integer type and can store a numerical value which has no fractional part, b will store a numerical value which has a fractional part and c will store an alphabet only. So as a fundamental data type, C language supports int, char and float data type. There are other data types also supported by C, which are Arrays, Structure, Union, Enumerated, Pointers etc. Which are used for different purposes.

When we declare a variable, it occupies space in memory. The space it occupied is called the size of variable. Different type of variable differs in size, and according to their size their storage capacity varies. Here are the size and storage capacity of varia

No comments:

Post a Comment