The ‘C’ Programming
language was originally development & implemented for unique operation
system.
‘C’ is a middle level
programming language. Development by “Deni’s Ritchie” in “1972” At “AT & T
bell lab” in USA. ‘C’ programming consists approximate 32 Keywords.
Characteristics of ‘C’: -
C has become a popular
programming language because of its many features. The important character
sticks of ‘C’ are-
# It is general purpose
programming language.
# It is a structured
programming language.
# It has rich set of
operators.
#It supports a rich set
of data type & show on.
‘C’ Tokens: -
The smallest individual
units of a ‘C’ programs is known as token. There are six tokens available in
‘C’ programs.
1-Keyword
2-Constant
3-Identifier
4-Strings
5-Special Keywords
6-Operators
Keywords: -
Keywords are those words
whose meaning have been fixed & is known, To its compiler, we can not
change the meaning of keywords, it we try to do so an error massage will
generates. So, we can say that keywords are the reserve words.
Example: - int, float,
double etc.
Identifiers: -
Identifiers are used for
naming program element that is variables, symbolic constant and arrays.
These are defined by the
user.
Constant: -
Data items that do not
change their values while the program execute, are called constant.
1-Nummeric Constant
a) Integer
b) Float or Real
2-Character Constant
a) Single Character
b) String
Constant (Double)
Variables: -
Variables are basically
memory locations, when hold some value in them. They are always assigned unique
name for identification.
The Quantity that changes
during the execution of a program is called a variable. Therefor variables are
also called as identifiers.
Rules for forming
variables name: -
# The first character of
a variable name must be an alphabet or an under score (_).
# Both upper case & lower-case
variable are significant in ‘C’.
# Keyword should not to be used as a
variable.
# Special character is not allowed.
Declaration of variables: -
The
declaration of variable in C information about: -
1-The name of a variable
2-The type of data to be stored by the
variable.
Syntax: -
data
type variable name:
Ex.- int a, char b, float c;
Operations: -
Operations are the symbols which is used for
performing the basic operation on the data value, operators are the variable of
a language that help the use perform computation of value.
There are following three types of operators available in ‘C’
programming.
1-Unary: -
i)
Increment
a)
Prefix
b)
Postfix
j)
Decrement
a)
Prefix
b)
Postfix
2-Binary:
i) Arithmetic
j) Logical
k) Assignment
l) Relational
m) Bitwise
n) special operator
3-Ternary:
-
i) Condition
Unary
operator: -
C
has
a class of operator that ate upon a single operant to give a new value. These
types of operation are known as unary operators. Unary operator also classified
into the two-basic category.
(i)
Increment operator: -
Operator
through which the value of operant to be increased.
Increment
operator also categorised into the two basic forms.
Example:
- # prefix: ++a;
# postfix: a++;
(ii)
decrement operator: -
Operator
through which the value of to be decrees by one. It is also divided into the two basic form.
Example:
- # prefix: --a;
# postfix: a--;
Binary
Operator: -
Binary
operators are these operators which act upon two operands. Hence the binary
operator also classified into the six basic categories.
#
Arithmetic Operatic: -
Arithmetic
Operator are used for performing most common operation of mathematics like
addition, subtraction etc.
Symbol
|
Meaning
|
+
|
Addition
|
-
|
subtraction
|
*
|
Multiplication
|
/
|
Division
|
%
|
Modul Division
|
Logical
Operators: -
Logical
operator operates upon two logical expressions to build more complex logical
expression which are either true or false.
Symbol
|
Meaning
|
&&
|
Logical And
|
||
|
Logical Or
|
!
|
Logical Not
|
Assignment
Operator: -
This
operator is to be used for assignment the value in a variable. It is denoted by
the symbol ‘=’.
Relational
operator: -
Relational
operators used in C programming for making the relational between two or more
variables.
Symbol
|
Meaning
|
>
|
Greater than
|
<
|
Less than
|
<=
|
Greater than
& Equal
|
>=
|
Less & Equal
|
==
|
Is Equal to
|
!=
|
Is not Equal to
|
Bitwise Operators: -
Bitwise operators of C language are the
operators, using which these type of operations are performed which are
generally performed through the low level languages. Bitwise operator specially
used for Bit manipulations.
Symbol
|
Meaning
|
& (Ampersand)
|
Bitwise
AND
|
| (Pipeline)
|
Bitwise
OR
|
^ (Caret)
|
Bitwise
x-OR
|
~ (1’s Complement )
|
Tilde
|
<< (Left shift)
|
Double
Less then
|
>> (Right shift)
|
Double
Grater than
|
Special Operators of C: -
‘C’ support same special operators such as
comma operator (,), size of () operator, arrow operator (→), Address operator
(&), and Dot operator (.).
# this () is parenthesis.
# this → is member selection operator.
# this (.) is period.
Turnery operator: -
The turnery operator (?), C includes a
very special operators called the turnery or conditional operators. It is
called turnery because it is used three
expression.
Like a short hand version of the if else
condition.
Syntax: -
Condition ? True statement : False statement;
Ex.: - x > y ? x : y;
CONTROL STRUCTURE: -
The control structure of a program is
divided into three sections.
# sequential structure programming.
# conditional \ Branching structure
programming.
# Looping \ Iteration structure programs.
sequential structure programming: -
when the control statements read all
programming statement in sequence called sequential structure programs.
conditional \ Branching structure programming:
-
when the control takes the design
according to the given conditions called condition structure programming.
Conditional structure programs divided
into the following statements.
# If Statement
# If else Statement
# Switch Statement
Condition structure programming: -
It classified into the
following concept: -
(i) If statement
Syntax: - If (condition)
{
Statement;
}
(ii)If else statement
Syntax: - If (condition)
{
Statement;
}
else {
statement;
}
(iii)switch statement (choice)
Syntax: -
switch(expression) {
Case
1: statement;
Break;
Case
2: statement;
Break;
:
:
Default: statement;
}
(iv)Nested statement:
Syntax: - If (condition)
{
Statement;
}
Else if
(condition) {
Statement;
}
:
:
Else {
Statement;
}
Looping structure programs: -
Many times, we require that a group of
instructions are to be execute until some logical condition are satisfied. It
is known as looping.
There are following loops available in C
programs.
·
While loop
·
Do while loop
·
For loop
·
Nested for loop
* While
loop syntax: - initial value;
while (test-condition) {
statement;
counter;
}
* Do while loop syntax: - initial
value;
do {
Statement;
Counter;
}
while
(test-counter)
* For
loop syntax: - for (initial-value; test-condition;
counter) {
Statement;
}
* Nested
for loop syntax: -
for (initial value; test-condition; counter)
{ // outer loop
for (initial value;
test-condition; counter) { //
inner loop
statement;
}
}