C Language: Livesoft @
C Language: Livesoft @
LiveSoft
C Language
Features
•C is a general purpose structured
programming language.
•C is powerful, efficient, compact &
flexible.
•C is highly portable
•C has a rich set of built-in functions
and operators that can be used to
write any complex program.
C Language
Features
•C is well suited for writing System
Software as well as Application
Software.
•C language allowes accessing of
memory locations with the help of
pointers which holds the address of
the memory location.
•C language allows dynamic allocation
of memory (at run time)
C Language
Structure of the C program
global declarations;
main()
{
local variables;
statements;
}
function1()
{
local variables;
Statements;
}
C Language
Data Types
•Data Type decides the type of data to
be accessed.
•C supports 4 classes of data types
•1) Primary (int, char, float, double)
•2) User-defined (typedef)
•3) Derived (Arrays, Pointers,
Structures, Unions, Enum)
•4) Empty (void)
C Language
Data Types
Data Type Memory Range of Values
char 1 byte 0 to 255
int 2 bytes -32,768 to 32,767
float 4 bytes 3.4e-38 to 3.4e+38
double 8 bytes 1.7e-308 to 1.7e+308
Ex: int sno, tot, sum;
char ch, op;
char sname[20];
float price;
C Language
Variables & Constants
•Variable : A variable is a data name
which can be used to store a data & a
variable may take different values at
different times, during execution of the
program.
•Constant : It is also a data name
which can be used to store a fixed
data & this data does not change
during execution of the program.
C Language
Operators
•Operators are symbols which
represent a particular operation that
can be performed on data.
•1) Arithmetic ( +, -, *, / )
•2) Increment & Decrement ( ++, -- )
•3) Modulo Division (%)
•4) Relational ( >, <, >=, <=, ==, != )
•5) Logical ( and &&, or ||, not ! )
C Language - Operators
•6) Assignment ( = )
•7) Conditional (?)
(it evaluates conditions)
[ max=(x>y)?x:y; ]
•8) Comma Operator (,)
(it permits different expressions to
appear in situations where only one
expression would ordinarily be used)
[ res=(a=5,b=6,a*b); ]
•9) Bit Wise ( ~, >>, <<, &, |, ^ )
C Language - Operators
•10) sizeof( ) operator: It returns the no.
of bytes occupied by the operand which
can be a variable, constant etc.