Documente Academic
Documente Profesional
Documente Cultură
ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UNIT-1
Introduction to Computer : The computer is derived from the word compute. A computer is an electronic
device that takes data and instructions as an input from the user, process data, and provides useful information
known as output. This cycle of operation of a computer is known as the input-process-output.
PROCESS
Characteristics of computer :
1 : Hardware components.
2 : Software components.
1
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 : Hardware Components : Hardware refers to the physical parts of the computer system.Hardware includes
the following components.
1 : Input devices.
2 : Processor.
3 : Output devices.
4 : Memory Management.
1 : System Software : A software which solve System Related problems.A System Software which interact
with hardware.
Programming Languages : The language used in the communication of computer instruction is known as
programming language.
1 : Machine Language :
Machine languages also called as 1st generation languages (1GL) and also called as low level language.
It id diffcult to understand and remember the various combinations of 1’s and 0’s representing data and
instructions.
2 : Assembly Language :
The assembly language also referred to as the second generation language(2GL) and also called as Low level
language.
Ex : mnemonic codes are LOAD, ADD, SUB, STORE, AND
2
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 : High level languages :
Creating and Running Programmes : A ‘C’ program has to pass through many phases for its
successful execution and to achieve the desired output. The various steps in the Executing a program written in
C involes a
Algorithms : Algorithm is a method of representing the step-by-step procedure for solving a problem. An
algorithm is very useful for finding the correct answer to a simple problem or a diffcult problem by breaking the
problem into simple cases.
Characteristics of Algorithms :
Efficiency of an Algorithm :
1 : Efficiency of an algorithm means, how fast it can produce the correct result for the given problem.
2 : Efficiency of an algorithm depends upon its time complexity and space complexity.
3 : Time complexity of an algorithm refers to the amount of computer time required for an algorithm for its
execution. This time includes both compile time and run time.
4 : Space complexity of an algorithm refers to the amount of memory required by the algorithm for its execution
and generation of the final output.
Flowchart Symbols
1 : Personal Computing Environment : if we are using a personal computer, all of the computer hardware
components are tied together in our personal computer. In this situation, we have the whole computer for
ourself, we can do whatever we want.
2 : Time-Sharing Environment : In the Time sharing environment, many users are connected to one or more
computers. These computers may be minicomputers or central mainframes. The terminals they use are often
nonprogrammable, although today we see more and more microcomputers being used to simulate terminals. In
the time sharing environmet, the output devices (such as printers) and secondary storage device(such as disks)
are shared by all of the user.
3 : Client / Server Environment : A client/ server computing environment splits the computing function
between a central computer and user’s computers. The users are given personal computers or workstations so
that some of the computation responsiability can be moved from the central computer and assigned to the
workstations. In the client/server environment, the user’s microcomputers or workstations are called the client.
The central computer, which may be a powerful microcomputer, minicomputer, or central mainframe systems is
called server.
Identifiers : Identifiers refer to the names of variables, functions and arrays. These are user-defined names is
called Identifiers.
Rules :
Ex : Valid Invalid
5
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
STDNAME Return
SUB $stay
TOT_MARKS 1RECORD
_TEMP STD NAME.
Y2K
Keywords : All keywords have fixed that means cannot be changed. Keywords serve as basic building
blocks for program statements. All keywords must be written in lowercase.The ‘C’ keywords are listed below.
3 : Constants : Constants refer to fixed values that do not change during the execution of a program.
C supports several kinds of constants.
CONSTANTS
11) What is variable? Rules of variables? Write some examples? (2M or 3M)
6
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Variables : A variable is an identifier that is used to represent some specified type of information . A variable
may take different values at different times during the execution. i.e it is the named memory location.
Rules :
Declaration of Variables : A variable can be used to store a value of any data type. The declaration of
variables must be done before they are used in the program. The general format for declaring a variable.
Ex : int x,y,z;
float a,b;
char m,n;
Assigning values to variables : values can be assigned to variables using the assignment operator (=). The
general format statement is :
7
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Ex : x=100;
a= 12.25;
m=’f’;
we can also assign a value to a variable at the time of the variable is declared. The general format of declaring
and assigning value to a variable is :
Ex ; int x=100;
float a=12.25;
char m=’f’;
Data Types : A datatype is a keyword/predefined instruction used for allocating memory for data.In order to
store data the program must reserve space which is done using datatype.
Input / Output (I/O) Functions : In ‘C’ language, two types of Input/Output functions are available, and
all input and output operations are carried out through function calls. Several functions are available for input /
output operations in ‘C’. These functions are collectively known as the standared i/o library.
8
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
printf() : output data or result of an operation can be displayed from the computer to a standard output device
using the library function printf(). This function is used to print any combination of data.
scanf() : input data can be entered into the computer using the standard input ‘C’ library function called
scanf(). This function is used to enter any combination of input.
Ex : scanf(“%d”,&a);
scanf(“%lf”,&sum);
The scanf() function is used to read information from the standard input device (keyboard).
1) Arithmetic Operators : The arithmetic operators perform arithmetic operations and can be classified
into unary and binary arithmetic operators.
They are Two unary arithmetic operators, plus (+), and minus (-)
They are Five binary arithmetic operators.
9
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The following table shows how the division operates on various data types.
2) Relational Operators : are used to compare two or more operands. Operands may be variables,
constants or expressions.
Each of these operators evaluates to the Boolean value. The Boolean value 0 indicates (false), 1
indicates (true).
3) Logical Operators : These operators are used to combine the results of two or more conditions. ‘C’ has
the following logical operators.
Logical AND : If any one condition false the complete condition becomes false.
Truth Table
Op1 Op2 Op1 && Op2
true true true
true false false
false true false
false false false
10
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Logical OR : If any one condition true the complete condition becomes true.
Truth Table
Op1 Op2 Op1 && Op2
true true true
true false true
false true true
false false false
Logical Not : This operator reverses the value of the expression it operates on i.e, it makes a true
expression false and false expression true.
Op1 Op1 !
true false
false true
4 ) Assignment Operator :Assignment operators are used to assign a value (or) an expression (or) a value of a
variable to another variable.
Ex : x=10;
y=20;
Compound assignment operator : ‘C’ provides compound assignment operators to assign a value to variable
in order to assign a new value to a variable after performing a specified operation.
5 ) Increment and Decrement Operator (Unary Operators) :The increment and decrement operators are
very useful in ‘C’ language.They are extensively used in for and while loop.
11
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The operator ++ adds 1 to the operand and – subtracts 1 from the operand. These operators in two forms :
prefix (++x) and postfix(x++).
Operator Meaning
++x Pre increment
- -x Pre decrement
x++ Post increment
x-- Post decrement
Where
6 ) Conditional (or) Ternary Operator : conditional operator checks the condition and executes the statement
depending of the condition. Conditional operator consist of two symbols.
It first evaluate the condition, if it is true (non-zero) then the “exp1” is evaluated, if the
condition is false (zero) then the “exp2” is evaluated.
7 ) Special Operators :
1 ) Comma Operator :The comma operator is used to separate the statement elements such as variables,
constants or expressions, and this operator is used to link the related expressions together, such expressions can
be evaluated from left to right and the value of right most expressions is the value of combined expressions.
2 ) Sizeof Operator : The sizeof() is a unary operator, that returns the length in bytes o the specified variable,
and it is very useful to find the bytes occupied by the specified variable in the memory.
Syntax : sizeof(variable-name);
int a;
Ex : sizeof(a); //OUTPUT-----2bytes
3 ) Pointer Operators :
8) Bitwise Operators : Bitwise operator s are used to manipulate the data at bit level. It operates on integers
only. It may not be applied to float.
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
<< Shift left
>> Shift right
~ One’s complement.
Expressions : An expression is a combination of operators and operands which reduces to a single value. An
operator indicats an operation to be performed on data that yields a value. An operand is a data item on which
an operation is performed.
Operator Precedence : Arithmetic Operators are evaluvated left to right using the precedence of operator
when the expression is written without the paranthesis.They are two levels of arithmetic operators in C.
1 : High Priority * / %
2 : Low Priority + -.
The order of evaluation can be changed by putting paranthesis is an expression.
Ex : 9-12/(3+3)*(2-1)
13
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Rules for Evaluation of Expression :
Associativity specifies the order in which the operators are evaluated with the same precedence in a
complex expression. Associativity is of two ways, i.e left to ringht and right to left. Left to right associativity
evaluates an expression starting from left and moving towards right. Right to left associativity proceds from
right to left.
If the condition is true, then the true statement will be executed otherwise the true statement
block will be skipped and the execution will jump to the statement-x. The ‘true statement’ may be a single
statement or group of statement.
If there is only one statement in the if block, then the braces are optional. But if there is more
than one statement the braces are compulsory.
If-else statement : The if-else statement is an extension of the simple if statement. The general form is :
If the condition is true , then the true statement and statement-x will be executed and if the condition
is false, then the false statement and statement-x is executed.
If there are only one statement in the if block or else block, then the braces are optional. But if there is
more than one statement the braces are compulsory.
Nested if-else statement : When a series of decisions are involved, we may have to use more than on if-else
statement in nested form.
If the condition-1 is false, the false statement-1 and statement-x will be executed. Otherwise it
continues to perform the second test. If the condition-2 is true, the true statement-2 will be executed otherwise
the false statement-2 will be executed and then the control is transferred to the statement-x
Switch statement : when there are several options and we have to choose only one option from the available
ones, we can use switch statement. Depending on the selected option, a particular task can be performed. A task
represents one or more statements.
Syntax : switch(expression)
{
case value1 : statement1;
case value2 : statement2;
case value3 : statement3;
.
.
case valueN : statementN;
default :
default-statement;
The expression following the keyword switch in any ‘C’ expression that must yield an integer value. It
must be ab integer constants like 1,2,3 .
The keyword case is followed by an integer or a character constant, each constant in each must be
different from all the other.
First the integer expression following the keyword switch is evaluated. The value it gives is searched
against the constant values that follw the case statements. When a match is found, the program executes the
statements following the case. If no match is found with any of the case statements, then the statements follwing
the default are executed.
Rules for writing switch() statement.
break : The keyword break allows the programmers to terminate the loop. The break skips from the loop or
block in which it is defined. The control then automatically goes to the first statement after the loop or block.
The break can be associated with all conditional statements.
continue : The keyword continue is exactly opposite to break. The continue statement is used for continuing
next iteration of loop statements. When it occurs in the loop it does not terminate, but it skips the statements
after this statement. It is useful when we want to continue the program without executing any part of the
program.
goto statement : goto statement doesnot require any condition. This statement passes control anywhere in the
program i.e, control is transferred to another part of the program without testing any condition.
The goto statement requires a label to identify the place to move the execution. A label is a valid variable name
and must be ended with colon ( : )
LOOP CONTROL STATEMENTS : Looping means a group of statements are executed repeatedly, until
some logical condition is satisfied.
17
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 : while loop
2 : do-while loop
3 : for loop
The while loop is an entry controlled loop statement, i.e means the condition is evaluated first and it
is true, then the body of the loop is executed. After executing the body of the loop, the condition is once again
evaluated and if it is true, the body is executed once again, the process of repeated execution of the loop
continues until the condition finally becomes false and the control is transferred out of the loop.
The body of the loop may have one or more statements, the blocking with the braces are needed only
if the body contains two or more statements.
Syntax : do
{
body of the loop;
}while (condition);
The do-while loop is an exit controlled loop statement The body of the loop are executed first and
then the condition is evaluated. If it is true, then the body of the loop is executed once again. The process of
execution of body of the loop is continued until the condition finally becomes false and the control is transferred
to the statement immediately after the loop. The statements are always executed at least once.
2 :Test-Condition :The value of the control variable tested using the condition and if it is true, the statements
are executed. When the statements are executed, the control is transferred back to the for loop after evaluating
the last statement in the loop.
3 : Increment / Decrement : Now, the control variable is incremented and the new value of the control variable
is again tested to see whether it satisfies the loop condition. If the condition is true, the statements are again
executed. The process of execution of statements is continued until the condition finally becomes false and the
control is transferred to the statement immediately after the loop.
1 : Hardware Components : Hardware refers to the physical parts of the computer system.Hardware includes
the following components.
1 : Input devices.
2 : Processor.
3 : Output devices.
19
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 : Memory Management.
1 : Input devices : Input device can be connected to the computer system using cables. The most commonly
used input devices are
1 : Keyboard.
2 : Mouse.
3 : Scanner.
Keyboard : A standard keyboard includes Escape Key, Function Keys, Alphanumeric Keys, Modifier Keys,
Spacebar Key, Cursor Movement Keys, Numeric Keypad, Special Keys. The Function Keys are the keys that
help perform a specific task such as searching a file or refreshing a web page. The modifier keys such as Shift
and Control Keys. The cursor movement keys include up, down, left and right keys. The spacebar key shifts the
cursor to the right by one position. The numeric keypad uses separate keypads for numbers and mathematical
operators.
Mouse : The mouse allows the user to select elements on the screen, such as tools, icons and buttons by
positioning and clicking them. We can also use a mouse to draw and paint on the screen of the computer
system. The mouse is also known as a pointing device.
The mouse consist of two buttons, a wheel at the top and a ball at the bottom of the mouse. The
wheel is used to scroll down in a document or a web page. When the ball moves, the cursor on the screen moves
in the direction in which the ball rotates. The left button of the mouse is used to select an element and the right
button, when clicked displays the special options such as open and explore and shortcut menus.
Scanner : Ascanner is an input device that converts documents and images as the digitized images
understandable by the computer system. The digitized images can be produced as blank and white images, gray
images or colored images. In case of colored images, an image is considered as a collection of dots with each
dot reoresenting a combination of red, green and blue colors. The properties of red, green and blue colors
assigned to a dot are together called as color description.
2 : Processor : The processor is also known as CPU (Central Process Unit). The CPU consist of Control
Unit(CU) nad ALU. CU stores the instruction set, which specify s the operations performed by the computer.
CU transfers the data and the instructions to the ALU for an arithmetic operation. ALU performs arithmeticl or
logical operations on the data received. The CPU help form the following hardware devices to process the data.
Motherboard : it refers to a device for connecting the CPU with the input and output devices. The components
on the motherboard are connected to all parts of a computer. Some of the components of a motherboard are :
Buses : Electrical pathways that transfer data and instructions among different parts of the computer. For
example, the data bus is an electrical pathway that transfers data among the microprocessor, memory and
input/output devices connected to the computer. The address bus transfers addresses of RAM and ROM.
System Clock : it is a clock used for synchronizing the activities performed by the computer. The electrical
signals that are passed inside a computer. As a result the system clock is faster, the processing speed of the
computer is fast.
Microprocessor : CPU components that performs the processing and controls the activities performed by the
different parts of the computer. The microprocessor is plugged to the CPU socket places on the motherboard.
20
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ROM : is a Chip that contains the permanent memory of the computer that stores information, which cannot be
modified by the end use.
RAM (Random Access Memory) : is a primary memory of a computer that stores information and programs,
until the computer is used. RAM is a chip that can be connected to the RAM slots in the motherboard.
3 : OUTPUT DEVICES : The data processed by the CPU is made available to the end user by the output
devices. The most commonly used output devices are :
1 : Monitor
2 : Printer
3 : Speaker.
4 : Plotter.
Monitor : A monitor is a outputdevice that produces visual displays generated by the computer. The monitor is
also known as screen, is connected as an external device using cables or connected either as a part of the CPU.
The display device is used for visual presentation of textual and graphical information.
The monitor can be classified as cathode ray tube (CRT) monitors or liquid crystal display
(LCD). The CRT monitors are large, occupy more space in the computer, whereas LCD monitors are thin, light
weighted and occupy lesser space.
Printer : The printer is an output device that transfers the text displayed on the screen onto the paper sheets that
can be used by the end user.
Dot matrix printer : are commonly used in low quality and high volume applications like invoice printing, cash
registers.
Inkjet printers : are slower than dot matrix printers and generate high quality photographic prints.
Laser printers : laser printer may or may not be connected to a computer to generate an output. These printers
consist of a microprocessor, RAM and ROM,they can produce high qualityprints in quicker time.
Speaker : The speaker is an electroechanical that converts an electrical signal into sound. They are attached to a
computer as output devices to provide audio output, such as warning sounds and internet audios.
Plotter : The plotter is an output device that is connected to a computer to print large documents, such as
engineering or constructional drawings. Plotters use multiple ink pens or inkjets with color cartridges for
printing. A computer transmits binary signals to all the print heads of the plotter. Each binary signal contains the
coordinates of where a print head needs to be positioned for printing.
4 : Memory Management : Memory Management can be classified as primary memory and secondary
memory.
21
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Primary Memory : The primary memory is represented as a set of locations with each location occupying 8
bits. Each bit in the memory is identified by a unique address. The data is stored in the machine-understandable
binay form in these memory locations. The commonly used primary memories are as follows.
ROM : ROM represents Read Only Memory that stores data and instructions, even when the computer is turned
off. It is the permanent memory of the computer where the contents cannot be modified by the end user. ROM
is a chip that is inserted into the motherboard.
RAM : RAM is the read/write memory in which the information is retained only as long as there is a regular
power supply. When the power supply is interrupted or switched off the information stored in the RAM is lost.
RAM is volatile memory.
Cache Memory : Cache memory is used to store the data and the related application that was last processed by
he CPU. When the processor performs processing, it first searches the cache memory and then the RAM.
Secondary Memory : represents the external storage devices that are connected to the computer. They provide
a non-voltatile memory. A stoage device is either located in the CPU of the computer or is connected externally
to the computer. The secondary storage device can be classified as
Magnetic storage device : The magnetic storage devices store information that can be read, erased and
rewritten a number of times. These includes floppy disk, hard disk.
Optical storage device : The optical storage device are secondary storage devices thatuse to read the stored
data. These include CD-ROM,rewritable compact disk (CD-RW), digital video disks with read only memory
(DVD-ROM).
Magneto-optical storage device : The magneto-optical devices are generally used to store information such as
large programs, files and back up data.
1 : System Software : A software which solve System Related problems.A System Software which interact
with hardware.
22
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Programming Languages : The language used in the communication of computer instruction is known as
programming language.
1 : Machine Language : The language which uses all instructions and data should be written using binary
codes 1 and 0 . The binary code is called machine code or machine language. Computers do not understand
English, Hindi and Tamil. They respond only to machine language. each computer has its own machine
language.
Disadvantages
1 : It id diffcult to understand and remember the various combinations of 1’s and 0’s representing data and
instructions.
2 : Since every machine has its own machine language.The user cannot communicate with other computers
Machine languages also called as 1st generation languages (1GL) and also called as low level language.
2 : Assembly Language :
1 : The assembly language also referred to as the second generation language(2GL) and also called as Low level
language.
2 : The assembly language the 0’s and 1’s of machine language are replaced with abbreviations or mnemonic
code.
3 : An assembly language instruction consist of a mnemonic code followed by 0 or more operands. The
mnemonic code is called operation code or opcode.
Ex : mnemonic codes are LOAD, ADD, SUB, STORE, AND
3 : High level languages : High level languages are like COBOL, Pascal, FORTRAN and C are more abstract,
easier to use, and more portable across platforms , as compared to low-level language.
23
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 : Problem-oriented languages : Problem-oriented languages are used to solve specific problems and also
called as fourth generation language (4GL). These include query languages, Report Generators and Application
Generators. A single statement in a fourth-generation can perform the same task as multiple lines of a third-
generation language.
3 : Natural languages : Natural languages are designed to make a computer to behave like an expert and solve
problems. These languages are known as fifth generation languages (5GL). Natuaral languages such as LISP
and PROLOG are mainly used to develop artificial intelligence and expet systems.
Creating and Running Programmes : A ‘C’ program has to pass through many phases for its
successful execution and to achieve the desired output. The various steps in the Executing a program written in
C involes a
1 : Creating the program
2 : Compilation phase
3 : Linking phase.
4 : Execution phase.
24
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 : Creating the program : The C program is entered into a file through a text editor. The program has been
written. The file is saved on the sisk with an extension of ‘.C’.
2 : Compilation phase : This phase is carried out by a program called as compiler. Compiler translates the
source code into the object code. The compilation phase cannot proceed successfully until and unless the source
code is error-free. If it encounters syntax error in the source code. The compiler generates message. The error-
frr source code is translated into the object code and stored in a separate file with an extension ‘.obj’.
25
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This can be done in ‘C language by pressing ALT +F9 or choose Compile option in the menu system.
3 : Linking the program with system library : ‘C’ language program is the collection of predefined functions.
These functions already written in some standard ‘C’ header files. Before executing a ‘C’ program we need to
link with system library. This can be done automatically at the time of execution.
4 : Executing the Program : in this phase, the executable object code is loaded into the memory and the
program execution begins. We may encounters during the execution phase.At this time there is a possibility to
show two types of errors given below.
1 : Logical Errors : These errors are Logic of the program. The programmer might be using a wrong formula
or the design of the program itself is wrong.
2 : Data Errors : These are the errors, in which the input data given is not in a proper sysntax as specified in
input statements.
Executing the program can be done pressing CTRL + F9 or choose Run option from the menu system.
Algorithms : Algorithm is a method of representing the step-by-step procedure for solving a problem. An
algorithm is very useful for finding the correct answer to a simple problem or a diffcult problem by breaking the
problem into simple cases.
Characteristics of Algorithms :
Efficiency of an Algorithm :
1 : Efficiency of an algorithm means, how fast it can produce the correct result for the given problem.
2 : Efficiency of an algorithm depends upon its time complexity and space complexity.
3 : Time complexity of an algorithm refers to the amount of computer time required for an algorithm for its
execution. This time includes both compile time and run time.
4 : Space complexity of an algorithm refers to the amount of memory required by the algorithm for its execution
and generation of the final output.
Flowchart Symbols
Software Development Life Cycle : The modern programming projects are built using a series of
interrelated phases commonly referred to as the software development life cycle.
One very popular development life cycle is the waterfall model. It describes the various phases
involved in the development.
27
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Systems Requirements
Analysis
Design
Coding
System Test
Maintenance
1 : Systems Requirements : In this phase, the systems analyst defines requirements that specify what the
proposed system is to accomplish. The requirements are usually stated in terms that the user understands.
2 : Analysis phase : In this phase of program development involves analyzing the problem in order to achieve
the objectives of the program.In this phase all the identified requirements are documented.
3 : Designing phase : This phase involves making the plan of action before actually starting the development
work. The plan is made on the basis of the program specifications identified in the previous phase. This phase
helps in framing the core structure of the program. In addition the designing phase has an added advantage of
modularity.
4 : Coding phase : This phase involves writing the instructions or code for the program on the basis of the
design document created in the previous phase. The choice of the programming language in which the program
will be developed is made on the type of program.
5 : System Test : After we have written our program, we must test it. Program testing can be a very tedious and
time-consuming part of program development. As the programmer, we are responsiable for completely testing
our program. In large development projects, there are often specialists known as system engineers who ar
responsiable for testing the system as a whole- that is for testing to make sure all the program works
together.There are two types of Testing.
1 : BlackBox Testing : is done by the system test engineer and the user.
2 : WhiteBox Testing : is the resposiability of the programmer.
6 : Maintenance : keeps the system working once it has been put into the production.
STRUCTURE OF C PROGRAMS
Every ‘C’ programe may contain one or more sections given below.
Documentation section
Preprocessor section
Definition section
Main()
{
Declaration part;
Executable part;
}
1 : Documentation section : It consist of a set of comment lines giving the name of the program, the author
and other details etc. Documentation section is a optional section.
Comments : means are very helpful in identifying the program features and underlaying logic of the program.
The lines begins with ‘/*’ and ending with ‘*/’ are known as comment lines. These are not executable, the
compiler is ignored any thing in between /* and */.
2 : Linker section : is also called preprocessor section. It provides instructions to the compiler to link functions
from the system library.
Ex : #include<stdio.h> ( standared input output header file ).
#include<conio.h> ( console input output header file )
Ex : #define PI 3.14
29
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 : Global Declaration : There are some variables that are used in more than one function. Such variables are
called global variables and are declared in the global declaration section that is outside of all the functions. This
section also declares all the user-defined functions.
5 : main() function : Every C program must have one main(0 function. This section contains two parts.
1 : Declaration part
2 : Executable part.
1 : Declaration part : This part is used to declare all the variables that are used in the executable part of the
program and these are called local variables.
2 : Executable part : It contains atleast one valid ‘C’ statement. The execution of a program begins with
opening brace ‘{‘ and ends with closing brace ‘}’. The closing brace of the main() function is the logical end of
the program.
All the statements in the program ends with a semicolon except conditional and control statements.
6 : sub program section : This contains all the user defined functions that are called in the main() function.
User defined functions are generally placed immediately after the main() function.
Ex :
/* program name : sample program
Author : jbrec
Language : C */
#include<stdio.h>
main()
{
printf(“This is First Programme”);
}
Programming Rules : The following rules should follow while writing a ‘C’ program.
1 : All statements in ‘C’ program should be written in lower case letters. Upper case letters are only used for
symbolic constants.
2 : The program statement can write anywhere between the two braces following the declaration part.
3 : The user can also write one or more statements in one line separating them with a semicolon.
4 : Blank spaces may be inserted between the words. It is not used while declaring a variable, keyword,
constant, and function.
C TOKENS : The smallest individual units are known as tokens. C has six types of tokens.
1 : Identifiers
2 : Keywords
3 : Constants
30
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 : Strings
5 : Special Symbols
6 : Operators.
1 : Identifiers : Identifiers refer to the names of variables, functions and arrays. These are user-defined
names is called Identifiers.
Rules :
Ex : Valid Invalid
STDNAME Return
SUB $stay
TOT_MARKS 1RECORD
_TEMP STD NAME.
Y2K
2 : Keywords : All keywords have fixed that means cannot be changed. Keywords serve as basic building
blocks for program statements. All keywords must be written in lowercase.The ‘C’ keywords are listed below.
3 : Constants : Constants refer to fixed values that do not change during the execution of a program.
31
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
C supports several kinds of constants.
CONSTANTS
1 : Decimal Integer
2 : Octal
3 : Hexadecimal
Ex : valid invalid
7 $77
77 077
+77 7,777
-77
2 : Octal : An integer constants with base 8 is called octal. These rules are :
EX : VALID INVALID
0123 123 -> it because no prefix with 0
+0123 0128 -> because digits from 0 to 7.
32
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-0123
Ex : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
b) it should prefix with 0X or 0x.
c) it allows sign (+,-).
d) No special character is allowed.
EX : OX1a, ox2f
Real Constants : Real constant is base 10 number, which is represented in decimal 0r scientific/exponential
notation.
Real Notation : The real notation is represented by an integer followed by a decimal point and the
fractional(decimal) part. It is possible to omit digits before or after the decimal point.
Ex : 15.25
.75
30
-9.52
-92
+.94
mantisha e exponent
The mantisha is either a real/floating point number expressed in decimal notation or an integer and the
exponent is an integer number with an optional sign. The character e separating the mantisha and the exponent
can be written in either lowercase or uppercase.
Ex : 1.5E-2
100e+3
-2.05e2
Single Character Constant : A character constant is either a single alphabet, a single digit, a single special
symbol enclosed within single inverted commas.
String constant : A string constant is a sequence of characters enclosed in double quote, the characters may be
letters, numbers, special characters and blank space etc
a) \n newline
b) \r carriage return
c) \t tab
d) \v vertical tab
e) \b backspace
f) \f form feed (page feed)
g) \a alert (beep)
h) \’ single quote(‘)
i) \” double quote(“)
j) \? Question mark (?)
k) \\ backslash (\)
Variables : A variable is an identifier that is used to represent some specified type of information . A variable
may take different values at different times during the execution. i.e it is the named memory location.
Rules :
Ex : int x,y,z;
float a,b;
char m,n;
Assigning values to variables : values can be assigned to variables using the assignment operator (=). The
general format statement is :
Ex : x=100;
a= 12.25;
m=’f’;
we can also assign a value to a variable at the time of the variable is declared. The general format of declaring
and assigning value to a variable is :
Ex ; int x=100;
float a=12.25;
char m=’f’;
Operators : An operator is a Symbol that performs an operation. An operators acts some variables are called
operands to get the desired result.
Ex : a+b;
Where a,b are operands and + is the operator.
Based on the operands on which operates it has been classified into 3 categories.
1) Unary Operator.
2) Binary Operator.
3) Ternary Operator.
1) Unary Operator : An operator which operands one operand is called Unary Operator.
EX : ++ , -- .
2) Binary Operator : An operator which operands two operands is called Binary Operator.
Ex : +, -, *.
3) Ternary Operator : An operator which operands three operands is called Ternary Operator.
Types of Operator :
35
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1) Arithmetic Operators.
2) Relational Operators.
3) Logical Operators.
4) Assignment Operators.
5). Unary Operators.
6) Conditional Operators.
7) Special Operators.
8) Bitwise Operators.
Data Types : A datatype is a keyword/predefined instruction used for allocating memory for data.In order to
store data the program must reserve space which is done using datatype.
1 : short int.
2 : int.
3 : long int.
In both signed and unsigned forms.
Floating Point Types : Floating point numbers are stored in 32 bits, with 6 digits of precesion. Floating point
numbers are defined in C by the keyword float.
A double data type number uses 64 bits giving a precision of 14 digits. These are known as double precision
numbers
Long double data type which uses 80 bits.
Character Type : A single character can be defined as a character type data(char). Characters are usually
stored in 8 bits. The qualifier signed or unsigned may be explicitly applied to char.
Void Type : The void type has no values. The type of a function is said to be void. When it does not return any
value.
Input / Output (I/O) Functions : In ‘C’ language, two types of Input/Output functions are available, and
all input and output operations are carried out through function calls. Several functions are available for input /
output operations in ‘C’. These functions are collectively known as the standared i/o library.
37
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I / O Functions
Formated I/O Functions : formatted I/O functions operates on various types of data.
1 : printf() : output data or result of an operation can be displayed from the computer to a standard output
device using the library function printf(). This function is used to print any combination of data.
Formating string : it prints all the character given in doublequotes (“ “) except formatting specifier.
38
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
printf(“%d”); -> no display
scanf() : input data can be entered into the computer using the standard input ‘C’ library function called
scanf(). This function is used to enter any combination of input.
The scanf() function is used to read information from the standard input device (keyboard).
Each variable name (argument) must be preceeded by an ampersand (&). The (&) symbol gives the meaning
“address of “ the variable.
1 : getchar() function : A single character can be given to the computer using ‘C’ input library
function getchar().
The getchar() function is written in standared I/O library. It reads a single character from a standared
input device. This function do not require any arguments, through a pair of parantheses, must follow the
statements getchar().
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char ch;
clrscr();
printf("Enter any character/digit:");
ch=getchar();
if(isalpha(ch)>0)
printf("it is a alphabet:%c\n",ch);
else if(isdigit(ch)>0)
printf("it is a digit:%c\n",ch);
else
printf("it is a alphanumeric:%c\n",ch);
getch();
}.
39
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 : putchar() function :The putchar() function is used to display one character at a time on the standared output
device. This function does the reverse operation of the single character input function.
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char ch;
printf("Enter any alphabet either in lower or uppercase:");
ch=getchar();
if(islower(ch))
putchar(toupper(ch));
else
putchar(tolower(ch));
getch();
}
3 : gets() : The gets() function is used to read the string (String is a group of characters) from the standard input
device (keyboard).
Ex :#include<stdio.h>
#include<conio.h>
void main()
{
char str[40];
clrscr();
printf("Enter String name:");
gets(str);
printf("Print the string name%s:",str);
getch();
}
4 : puts() :The puts() function is used to display the string to the standared output device (Monitor).
#include<stdio.h>
#include<conio.h>
void main()
{
char str[40];
puts("Enter String name:");
gets(str);
puts("Print the string name:");
puts(str);
getch();
}
OUTPUT :Enter string name :
jbrecit
Print the string name
jbrecit
Operators : An operator is a Symbol that performs an operation. An operators acts some variables are called
operands to get the desired result.
Ex : a+b;
Where a,b are operands and + is the operator.
Based on the operands on which operates it has been classified into 3 categories.
1) Unary Operator.
2) Binary Operator.
3) Ternary Operator.
1) Unary Operator : An operator which operands one operand is called Unary Operator.
EX : ++ , -- .
2) Binary Operator : An operator which operands two operands is called Binary Operator.
Ex : +, -, *.
3) Ternary Operator : An operator which operands three operands is called Ternary Operator.
Types of Operators :
1) Arithmetic Operators.
2) Relational Operators.
3) Logical Operators.
4) Assignment Operators.
41
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
5). Unary Operators.
6) Conditional Operators.
7) Special Operators.
8) Bitwise Operators.
9) Shift Operators.
1) Arithmetic Operators : The arithmetic operators perform arithmetic operations and can be classified
into unary and binary arithmetic operators.
They are Two unary arithmetic operators, plus (+), and minus (-)
They are Five binary arithmetic operators.
The following table shows how the division operates on various data types.
2) Relational Operators : are used to compare two or more operands. Operands may be variables,
constants or expressions.
42
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Each of these operators evaluates to the Boolean value. The Boolean value 0 indicates (false), 1
indicates (true).
3) Logical Operators : These operators are used to combine the results of two or more conditions. ‘C’ has
the following logical operators.
Logical AND : If any one condition false the complete condition becomes false.
Truth Table
Op1 Op2 Op1 && Op2
true true true
true false false
false true false
false false false
Logical OR : If any one condition true the complete condition becomes true.
Truth Table
Op1 Op2 Op1 && Op2
true true true
true false true
false true true
false false false
Logical Not : This operator reverses the value of the expression it operates on i.e, it makes a true
expression false and false expression true.
Op1 Op1 !
true false
false true
4 ) Assignment Operator :Assignment operators are used to assign a value (or) an expression (or) a value of a
variable to another variable.
43
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Syntax : variable name=expression (or) value
Ex : x=10;
y=20;
Compound assignment operator : ‘C’ provides compound assignment operators to assign a value to variable
in order to assign a new value to a variable after performing a specified operation.
5 ) Increment and Decrement Operator (Unary Operators) :The increment and decrement operators are
very useful in ‘C’ language.They are extensively used in for and while loop.
The operator ++ adds 1 to the operand and – subtracts 1 from the operand. These operators in two forms :
prefix (++x) and postfix(x++).
Operator Meaning
++x Pre increment
- -x Pre decrement
x++ Post increment
x-- Post decrement
Where
6 ) Conditional (or) Ternary Operator : conditional operator checks the condition and executes the statement
depending of the condition. Conditional operator consist of two symbols.
44
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It first evaluate the condition, if it is true (non-zero) then the “exp1” is evaluated, if the
condition is false (zero) then the “exp2” is evaluated.
7 ) Special Operators :
1 ) Comma Operator :The comma operator is used to separate the statement elements such as variables,
constants or expressions, and this operator is used to link the related expressions together, such expressions can
be evaluated from left to right and the value of right most expressions is the value of combined expressions.
2 ) Sizeof Operator : The sizeof() is a unary operator, that returns the length in bytes o the specified variable,
and it is very useful to find the bytes occupied by the specified variable in the memory.
Syntax : sizeof(variable-name);
int a;
Ex : sizeof(a); //OUTPUT-----2bytes
3 ) Pointer Operators :
8) Bitwise Operators : Bitwise operator s are used to manipulate the data at bit level. It operates on integers
only. It may not be applied to float.
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
<< Shift left
>> Shift right
~ One’s complement.
Conditional statements (Decision making Statements) : moving execution control from one place/line to
another line based on condition. ‘C’ language supports two conditional statements.
45
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 : if
2 : switch.
1 : simple if statement.
2 : if –else statement
3 : nested if-else statement.
4 : else if ladder.
If the condition is true, then the true statement will be executed otherwise the true statement
block will be skipped and the execution will jump to the statement-x. The ‘true statement’ may be a single
statement or group of statement.
If there is only one statement in the if block, then the braces are optional. But if there is more
than one statement the braces are compulsory.
Rules of if statement :
1 : The condition is always enclosed within a pair of parenthesis.
2 : The conditional statement should not be terminated with semi-colons ( ; ).
3 : The curly braces indicates the scope of the if statement.
4 : The default scope is one statement. But it is a good practice to use curly braces even with a single statement.
If-else statement : The if-else statement is an extension of the simple if statement. The general form is :
If the condition is true , then the true statement and statement-x will be executed and if the condition is
false, then the false statement and statement-x is executed.
If there are only one statement in the if block or else block, then the braces are optional. But if there is
more than one statement the braces are compulsory.
46
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested if-else statement : When a series of decisions are involved, we may have to use more than on if-else
statement in nested form.
If the condition-1 is false, the false statement-1 and statement-x will be executed. Otherwise it
continues to perform the second test. If the condition-2 is true, the true statement-2 will be executed otherwise
the false statement-2 will be executed and then the control is transferred to the statement-x
if-else ladder : The if else ladder is used when multipath decisions are involved. A multipath decision is a chain
of ifs in which the statement associated with each else is an if.
Switch statement : when there are several options and we have to choose only one option from the available
ones, we can use switch statement. Depending on the selected option, a particular task can be performed. A task
represents one or more statements.
Syntax : switch(expression)
{
47
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
case value1 : statement1;
case value2 : statement2;
case value3 : statement3;
.
.
case valueN : statementN;
default :
default-statement;
}
The expression following the keyword switch in any ‘C’ expression that must yield an integer value. It
must be ab integer constants like 1,2,3 .
The keyword case is followed by an integer or a character constant, each constant in each must be
different from all the other.
First the integer expression following the keyword switch is evaluated. The value it gives is searched
against the constant values that follw the case statements. When a match is found, the program executes the
statements following the case. If no match is found with any of the case statements, then the statements follwing
the default are executed.
LOOP CONTROL STATEMENTS : Looping means a group of statements are executed repeatedly, until
some logical condition is satisfied.
1 : while loop
2 : do-while loop
3 : for loop
48
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The while loop is an entry controlled loop statement, i.e means the condition is evaluated first and it
is true, then the body of the loop is executed. After executing the body of the loop, the condition is once again
evaluated and if it is true, the body is executed once again, the process of repeated execution of the loop
continues until the condition finally becomes false and the control is transferred out of the loop.
The body of the loop may have one or more statements, the blocking with the braces are needed only
if the body contains two or more statements.
Syntax : do
{
body of the loop;
}while (condition);
The do-while loop is an exit controlled loop statement The body of the loop are executed first and
then the condition is evaluated. If it is true, then the body of the loop is executed once again. The process of
execution of body of the loop is continued until the condition finally becomes false and the control is transferred
to the statement immediately after the loop. The statements are always executed at least once.
The for loop is another entry-controlled loop. The execution of the for loop is as follows.
49
JOGINPALLY B. R. ENGINEERING COLLEGE
B.Tech-I Year COMPUTER PROGRAMMING NOTES
D.Murali Mohan K. Praveen Kumar P.Sandya A. Raju
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 : Initilization :Initialization of the control variables is done.
2 :Test-Condition :The value of the control variable tested using the condition and if it is true, the statements
are executed. When the statements are executed, the control is transferred back to the for loop after evaluating
the last statement in the loop.
3 : Increment / Decrement : Now, the control variable is incremented and the new value of the control variable
is again tested to see whether it satisfies the loop condition. If the condition is true, the statements are again
executed. The process of execution of statements is continued until the condition finally becomes false and the
control is transferred to the statement immediately after the loop.
50