C is a robust language. means rich set of built in functions and operators can be used to write any complex program.
Programs written in C are efficent and fast.
There are 32 keywords and several standard functions are available which can be used for developing program.
c is highly portable. this means that c programs written for one computer can be run on another with litte or no modification.
c programing language is structred programming language. means data can be written in module or function or blocks.
a proper collection of these modules make a complete program.
A simple Program
/* printing begin */
printf(""This is my first program");
} /* this is main block closed */
Execution of C program
1) Createing the program
2) compiling the program
3) Linking the program with functions that are needed from the C Library
4) Executing the Program.
Ms Dos operating system would load program stored inthe file .c generate the Object Code this code stored in another file name is
which generate the executeable code with file name is .exe
text data, individualwords and puncuation marks are called tokens
c tokens are
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
A integer constant refers to a sequence of digits. There 3 types
Decimal, octal and hexadecimal.
Decimal consists 0.......9 preceded by an + or – sign.
Hidden spaces, commas,and non-digit charagacter s are not permitted between digits.
An octal number consists of any combination of digits from the set 0 through 7 with a leading 0.
A sequence of digits preceded by 0x and 0X theymay also include alphabets A through F for a through f.ex:
Integer numbers are inadequate to represent quantities that vary coninuously. Such as distance , heights ,price etc...
A real number may be expressed in decimal notation or an integer.
Single character constants
Backslash character constants
‘\f’ form feed
‘\n’ new line
‘\t’ Harizantal tab;
‘\v’ vertical tab;
‘\” single quote
‘\” ‘ double quote
Primary data types
Singen type unsigned type
Int unsigned int
Short int unsigned short int
Long int unsinged long int
Char -128 to 127
Int -32,768 to 32,767
Float 3,4e-38 to 3.4e+38
Double 1.7e-308 to 1.7e+308
Size and Range of Data Types(bits)
Char 8 -128 to 127
Int 16 0 to 255
Short Int 8 -128 to 127
Long 32 -2,147,483,648 to 2,147,483,647
Float 32 3.4E-38 to 3.4e+38
Double 64 3.4E-4932 to 1.1E+4932
How we Declare a Variable
After design a suitable variable names
1). It tells the compiler what the variable name
2) It specifies what type of data the variable will hold.
Data – type v1,v2,v3;
C supports a feature as type definition that allows users to define an identifier that would represent an existing data type.
Typedef type identifier
Typedef int units;
Long int n;
Declaring a variable as constant
The value of certain variables to remain constant during the execution of a program.
Const int size=30;
C supports set of operators. Like are =,+ - * & and < >
1) Arithmetic operatos
2) Relational operators.
3) Logical operators.
4) Assignment operators.
5) Increment and decrement operator
6) Conditional operator
7) Bitwise operators
8) Special operators.
C language provide basic operators are +, -, /, %, *
+ ----------- Addition
- ------ subtraction
* ---- multiplication
/ ------ division
% ------ modulo division
Modulo division operator % cannot be used on floating point data.
Here a,b are operands.
Integer arithmetic always get an integer value.
If a=14 , b=4 then
if you give like this
If u give like
These operator used for compare two depending on their relation. Take certain decisions.
The operators are
Less then or equal
Greaterthen or equal
Not equal to
&& ---- logical AND
|| ---- logical OR
! --- logical NOT
The logical && and || are used for test more than one condition and make ecisions.
To assign the result of an expression to a variable.
Assign operator =
We can write like this
INCREMENT AND DECREMENT OPERATOR
The increment and decrement are 4 types
Pre increment ++p;
Post increment p++;
Pre decrement --p;
Post decrement p--;
These operator used for while looping to automatically increment are decrement a value.
A ternary operator used for to test a single condition
Exp1 ? Exp2 : exp3;
BIT WISE OPERATORS
This is used for manipulation of data at bit level these operator used for testing the bits,
Shift bit s left to right or right to left
Bitwise opertors are not used on float or double.
& ,| , ^ ,<<, >>,~