C nOTES
C nOTES
Algorithm
Flow Chart
Code into Light level Languages
Input Preparation
Compilation
Corrections
Test Process
The first step in lives while developing a programme is Algonthm to represent the paper.
The second step for developing a programme is called flow chatting. Flow chating
means the digramaticaug representation of comp programe following are the symbols
ureel in flow charts
The next step for developing a computer programming to writing code into ligh
level language. That mean writing a progrmme into a ligh level language, using prison
Ted format for programme. It mean write instruction 8 Command which are regavd for
that programme in ligh level language.
Next step is preparing output. The next step is compilcation that mean to conveat
the ligh level language into machine level language with the usr of compiler. Of there are
errors it display that errors which are accused by you & the last steps is – Test proscenia
exsiccation of programme.
Note :- C Language is middle level language tecaure it has Characteristics of ligh level
language & level language.
Importance of ‘C’
Programme written in ‘C’ are efficient & fast. This alue to its rariety of data types &
powerful operations.
It is many time faster than basic.
There are only 32 keywords & its strength lies in its built in functions.
Several Standred functions are available ‘C’ can be used for developing a
programme ‘C’ to lightly portable to mean that ‘C’ Programming written for one
computer can be run on another well -------------------- or no modification.
??= #
??( [
??) ]
??< {
??> }
??!
??/ \
??’ ^
??- ~
, Comma
. Paved
; Semicolon
?
: Apostrophe
“ Quotation mark
! Exclamation
Vertical bar
/ F. slash
\ B. slash
~ Tilde
_ Underscore
$ Dollar sign.
%
# Hash
& Amper Sand
^ Canet
* Asteric
__ Minus
+ Plus
< Les than
> Greater than
( Left parenthesis
) Right parenthesis
[ Left bracket
] Right bracket
{ Left brace
} Right brace
Identifier
Reefers to the name
Of variables, function & arrays. There are user defined names consist of sequence of
letter & digit with a letters as a first character both uppercase and lowercase letters are
permitted although lower case letters are commonly. The under score character is also
permitted in identifier.
Constants
Constants in C refers to fixed values that do not change during the execution of
programme C supports several types of const. They are as
Constant
Note :- Spaces, Commas & non digit Char are not permitted bet digits.
Octal constant
An octal int const consist of any combination of digit from the set of 0 – 7 with a leading
‘o’ zero eg – 0,3,2,7, 0, 0,4,5,3.
* Hexadecimal Constant
A seq. of digits preceded by 02 or ox is Consider as hexadecimal integer. They
may also include alphabet A – F or a – f following are the eg.
0x2
0 x 1F
0 x bcd.
we rarely use octal and hexadecimal nos in programming.
C) String Constant
A string constant is a set of characters enclosed within a double quote “ ” The
character may be letters, numbers sepelial characters & blank space eg.- one “helo” /
“1987” / “ well done “ / eeg “?……!” / “5+3” / “X”
Remember that a character const ‘X’ is not equvalant to string const “X” further a
single character string const doc not have an equralant integer value while.
Character strings are often use to built meaning – ful programmes.
Variables
A available is a data name may be used to store a data values unlike const that remain
changed during the execution of a programme a variable may take different. Values at
different times during execution.
A variable name can be choosen by the programmer in a mearingful way so as to
refrect its funnor nature in the programme. Some eg. Of such name are – Average.
Light
Total
Counter_1
Class_ Strength
As mentaioned eariar verable name may consist letters, digit & the undersore
characters, Sub. To the following condn-
They must begging – a letters.
Some sys. Permit underscore as the first character.
ANSI recognizes a length of 31 Characters however the lengh should be eight character
since only the first 8 characters are prated as significant by many compilers.
The upper case & lower case are significant ie. the veiable Total, is not same as total or
TOTAL.
The variable name should not be a keyword.
Blank space is not allowed.
DATA TYPES
‘C’ language is rich in its data types. Srorage representation & machin instruction to
handle constants differ from machine to machine. The vaiety of data types available
allow the programmer to select the type appropriates to needs of the application as well
as the machine.
‘C’ supports 4 classe of data type.
Primary data types.
User – defined data types.
Derived data types.
Empty data sete.
Integer Character
Delcleration of Veravles
After designing suitable veriable name you must delclear them to the compler,
Dedlaration does now things
It tells the compiles what is the name of veiable.
Its specifies that , what type of date type veriable will hold.
The declaration of veriales must be done before they are word in the programme
arithmetic operator
‘C’ provides all the basic arithmetic operator like +, -, x, :- , etc. these can
operate on any built in data type allowed in ‘C’ the anargoperatior in effect multiplay its
apearand by – 1 therfore a number preceded by – signed changes its signed.
+ add n or anary plus.
- substtraction , unary minus
* multiplication
/ division
% modulo division
the modulo division producs the reminder of an intger division eg. Of aritmatic
operator are
Relational operator
We often compair two quantities & depending on their relation to take a qrfain decigion
eg. – we may compair age of two person or the prise of two items & so on. These
comparison can be done with the help of relationl operator & expressions such as ---
a<b. or 1<20
Containing a relational operator is turned as a relational expression the vale of
relational expession is either one or zero. Itnisn one if the specified relation is true
otherwise zero.
Eg. --- 10<20 --- true (1)
20<10 --- false (0)
‘C’ supports 6 relational operators as follows.
Logical Operators
In addition to relational operator ‘C’ has following 3 operators.
OP–1
OP–2
Value of excretion
Non Zero
Non Zero
1
1
Non Zero
0
0
1
0
Non Zero
0
1
0
0
0
0
A=a+1 a+=1
A=a- 1 a- = 1
A = a * (n-1) a * = (n - 1)
A = a /(n+1) a / = (n + 1)
A=a%b a%=b
The use nof short hand operator has 3 advantages.
What appears on the C Left hand Side need not be repeated & therefore it becomes easier
to write.
The statement is more concise & easier to read.
The statement is more efficient eg. Value (5*J-2) = value (5*J-2) + data.
Using short hand operator value (5*J-2) + = data.
C type. H----
This is another system file like < stdio .h >, <math . h > This file contains the
character funn. Like.
Putchar ( )
This function is used for single character output it is a output function.
Syntax----
Variable = putchar ( ) ;
Switch statement -----
‘C’ has a built in multiway decision statements known as a switch.
The switch statements test the value of given variable (expression) against the cost of
case values & when the match is found a block of statement associated with case is
executed. The general form of switch statement is as follows ---.
The expression is an integer expression or characters.
Switch (expression)
{
Case value 1 :
Black 1 ;
Break ;
Case value 2 ;
Block 2 ;
Break ;
!!!!
Default
Default block ;
}
Statement x
When a stwich is executed the value of expression is succe ssively compaired
against values 0, value 1, value 2. If case is found whose matcher with the values of
expression then that block of statement that fallows the case are executed.
ARRAY
An “array” is a group of related data items that share a common away name salary
to represent a set of salaries of a employees. A particular sub- script in bracelet after the
array name eg. Salary [10] subscript
Represent the salary of the 10 the emplayce while the complcte set of values is
referred while the complete set of values values are called elements. Arrays can be of
any variable type.
Single dimensional or one-dimensional arrays -----
A list of items can be given variable name using only one subscript c such a
variable or one-dimensional array.
The subscript can begin E no O lie. Allowed eg. – it we want to reprenent a set of
five no say (35,42,20,57,90) by an array variable now. Then we may declea it as follows.
Int number [s];
And the comp reserres 5 storage location as shown below3
35
40
20
57
90
Number [0]
Number [1]
Number [2]
Number [3]
Number [4]
POINTERS
Pointers are the important feature of ‘C’ language. They are the powerful tools.
These are no of reasons for using the pointers.
Pointers enables us to access the veriable that is define outside the funn.
Pointers are more efficient in handling data tables (row & colum data rearranges).
Pointer reduces the length to & complicity of a programme.
They increase the execution speed.
The use of pointer array to char strings result in saving a data storage space in memory.
Eg. – int qty = 179
qty – variable name
179 – value.
5000 – address.
As you know comp. User their memory for storing instruction of a program. As
well as the value of a variable that are associated with it. The comp. Memory is a
sequential collection of storage cell. Commonly knows as byte & its has a number called
adderss. The add. Are the numbers consecutively starting from O the last add depends on
the memory size. The camp syst having 64 m3 memmory will have last adders 65535.
when even we deelear a veiable. The systems allocates some where in the memory and
appropriate location to whole the values viable since very byte has unique address.
Eg. – int aty = 179
This statement instruet the system. To find location for int. variable
Assume that system has chosen the add. Location five thousand for qty during the
execution of program the system. Always associate the name qty with the address five
thousand we may have acces the value 179 by using eitmer mane aly of the add 5000
since the memory address are simply number they can be assign to some variable which
can be stored in memory like any other viable. Such variable that hdd memory address.
Are called pointers.
A pointer is there for nothing but a veriable that contains an add. Which is
location of another variable in memory remember since a pointer is a variable its value is
also stored in the memory in another location suppose 1 asign the add. Of quantity &
veriable p . the link betn variable & and aty I s snown in following fig.
The address of p is 5048 since the value of variable quantity. We may access the,
value of qty by using the value of p and therefore which say that the variable p point to
the variable qty than p gets name pointer.
*Assessing the value of variables –
The location of the variable in the memory is syst dependant & there fore the add
of variable is not known to us immediathy. This can be done with the help of operator
address in C. the operator & immediately preceding a variable retan the the add. Of the
variable associated with it
Eg. – P = & city
P = 5000
Int qty, n, * P ;
Qty = 179
N = * pi
The first line decleare qty and. An as int variable and P is a pointer variable.
Pointing to as int the second time assign the values 179 to qty. At the third line
assig1
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
51515151515151515151515151515151515151515151515151515151515151515151515
15151515151515151515151515151515151515151515151515151515151515151515151
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616161616161616161616161616161616161616161616161616
16161616161616161616161616161616161616161616161616161616161616161616161
61616161616161616161616