[go: up one dir, main page]

0% found this document useful (0 votes)
17 views61 pages

Module 1

Uploaded by

sanatabasum2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views61 pages

Module 1

Uploaded by

sanatabasum2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Programming With C UNIT 1

UNIT – I

Algorithm, flowchart, program development steps, structure of C program, Compilers, Linker,


Preprocessor, identifiers, basic data types and sizes, Constants, variables, operators, expressions,
type conversions, conditional expressions, precedence and order of evaluation. Input-output
statements ,statements and blocks, programming examples.

Introduction to Computers:
Computer Systems:
A computer is a system made of two major components: hardware and software. The computer
hardware is the physical equipment. The software is the collection of programs (instructions) that
allow the hardware to do its job.

Computer
System

Hardware Software

Computer Hardware
The hardware component of the computer system consists of five parts: input devices, central
processing unit (CPU) ,primary storage, output devices, and auxiliary storage devices.

The input device is usually a keyboard where programs and data are entered into the computers.
Examples of other input devices include a mouse, a pen or stylus, a touch screen, or an audio
input unit.

The central processing unit (CPU) is responsible for executing instructions such as arithmetic
calculations, comparisons among data, and movement of data inside the system. Today’s
computers may have one ,two, or more CPUs .Primary storage ,also known as main memory, is
a place where the programs and data are stored temporarily during processing. The data in
primary storage are erased when we turn off a personal computer or when we log off from a
time-sharing system.

Prepared by T.Aruna Sri, Dept of CSE Page 1


Programming With C UNIT 1

The output device is usually a monitor or a printer to show output. If the output is shown on the
monitor, we say we have a soft copy. If it is printed on the printer, we say we have a hard copy.

Auxiliary storage, also known as secondary storage, is used for both input and output. It is the
place where the programs and data are stored permanently. When we turn off the computer, or
programs and data remain in the secondary storage, ready for the next time we need them.

Computer Software
Computer software is divided in to two broad categories: system software and application
software .System software manages the computer resources .It provides the interface between the
hardware and the users. Application software, on the other hand is directly responsible for
helping users solve their problems.

Software

System Application
software software

System System General Application


Operating
support Developmen Purpose Specific
Systems

Fig: Types of software

System Software:

System software consists of programs that manage the hardware resources of a computer and
perform required information processing tasks. These programs are divided into three classes:
the operating system, system support, and system development.

The operating system provides services such as a user interface, file and database access, and
interfaces to communication systems such as Internet protocols. The primary purpose of this
software is to keep the system operating in an efficient manner while allowing the users access to
the system.

System support software provides system utilities and other operating services. Examples of
system utilities are sort programs and disk format programs. Operating services consists of
programs that provide performance statistics for the operational staff and security monitors to
protect the system and data.

The last system software category ,system development software, includes the language
translators that convert programs into machine language for execution ,debugging tools to ensure
that the programs are error free and computer –assisted software engineering(CASE) systems.

Prepared by T.Aruna Sri, Dept of CSE Page 2


Programming With C UNIT 1

Application software

Application software is broken in to two classes :general-purpose software and application –


specific software. General purpose software is purchased from a software developer and can be
used for more than one application. Examples of general purpose software include word
processors ,database management systems ,and computer aided design systems. They are labeled
general purpose because they can solve a variety of user computing problems.

Application –specific software can be used only for its intended purpose.
A general ledger system used by accountants and a material requirements planning system used
by a manufacturing organization are examples of application-specific software. They can be used
only for the task for which they were designed they cannot be used for other generalized tasks.

The relationship between system and application software is shown in fig-2.In this
figure, each circle represents an interface point .The inner core is hard ware. The user is
represented by the out layer. To work with the system ,the typical user uses some form of
application software. The application software in turn interacts with the operating system ,which
is apart of the system software layer. The system software provides the direct interaction with the
hard ware. The opening at the bottom of the figure is the path followed by the user who interacts
directly with the operating system when necessary.

Computing Environments:
In the early days of computers, there was only one environment: the main frame computer
hidden in a central computing department. With the advent of mini computers and personal
computers, the environment changed, resulting in computers on virtually every desktop.

Personal Computing Environment


In 1971,Marcian E.Hoff, working for Intel, combined the basic elements of the central
processing unit into the microprocessor. The first computer on a chip was the Intel 4004 and was
the grandparent many times removed of Intel’s current system.
If we are using a personal computer, all of the computer hardware components are tied
together in our personal computer(PC).

Prepared by T.Aruna Sri, Dept of CSE Page 3


Programming With C UNIT 1

Time-Sharing Environment
Employees in large companies often work in what is known as a time-sharing environment. In
the times-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. Also, in the time-sharing environment, the output devices and auxiliary
storage devices are shared by all of the users.
A typical college lab in which a minicomputer is shared is shared by many students is shown in
figure :

In the time-sharing environment ,all computing must be done by the central computer. The
central computer has many duties: It must control the shared resources; it must manage the
shared data and printing and it must do the computing.

Client/Server Environment
A client/server computing environment splits the computing function between a central
computer and users’ computers. The users are given personal computers or work stations so that
some of the computation responsibility can be moved from the central computer and assigned to
the workstations. In the client-server environment, the users’ micro computers or workstations
are called the client. The central computer, which may be a powerful microcomputer,
minicomputer, or central mainframe system, is known as the server. Because the work is now
shared between the users’ computers and the central computer, response time and monitor
display are faster and the users are more productive.

Prepared by T.Aruna Sri, Dept of CSE Page 4


Programming With C UNIT 1

Distributed Computing
A Distributed Computing environment provides a seamless integration of computing
functions between different servers and clients .The internet provides connectivity to different
servers throughout the world. For example eBay uses several computers to provide its auction
services. This environment provides a reliable, scalable, and highly available network.
Fig: Distributed Computing

Computer Languages:
To write a program for a computer, we must use a computer language. Over the years computer
languages have evolved from machine languages to natural languages.

1940’s Machine level Languages


1950’s Symbolic Languages
1960’s High-Level Languages

COMPUTER LANGUAGES
In all over the world, language is the source of communication among human beings. Different
countries/regions have different languages. Similarly, in order to communicate with the

Prepared by T.Aruna Sri, Dept of CSE Page 5


Programming With C UNIT 1

computer user also needs to have a language that should be understood by the computer. For this
purpose, different languages are developed for performing different types of work on the
computer.Basically, languages are divided into two categories according to their interpretation.

1. Low Level Languages.

2. High Level Languages.


Low Level Languages

Low level computer languages are machine codes or close to it. Computer cannot understand
instructions given in high level languages or in English. It can only understand and execute
instructions given in the form of machine language i.e. language of 0 and 1. There are two types
of low level languages:

 Machine Language.
 Assembly Language
Machine Language: It is the lowest and most elementary level of Programming language and
was the first type of programming language to be Developed. Machine Language is basically the
only language which computer Can understand. In fact, a manufacturer designs a computer to
obey just one Language, its machine code, which is represented inside the computer by a String
of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of Electric pulse and 1 for the
presence of an electric pulse . Since a computer is Capable of recognizing electric signals,
therefore, it understand machine Language.
Advantages of Machine Language

i) It makes fast and efficient use of the computer.

ii) It requires no translator to translate the code i.e.Directly understood by the computer

Disadvantages of Machine Language:

i) All operation codes have to be remembered

ii) All memory addresses have to be remembered.

iii) It is hard to amend or find errors in a program written

In the machine language

iv) These languages are machine dependent i.e. a particular

Machine language can be used on only one type of computer


Assembly Language

It was developed to overcome some of the many

Prepared by T.Aruna Sri, Dept of CSE Page 6


Programming With C UNIT 1

inconveniences of machine language. This is another low level but a very important language in
which operation codes and operands are given in the form of alphanumeric symbols instead of
0’s and l’s. These alphanumeric symbols will be known as mnemonic codes and can have
maximum up to 5 letter combination e.g. ADD for addition, SUB for subtraction,
START,LABEL etc. Because of this feature it is also known as ‘Symbolic Programming
Language’. This language is also very difficult and needs a lot of practice to master it because
very small

English support is given to this language. The language mainly helps in compiler orientations.
The instructions of the Assembly language will also be converted to machine codes by language
translator to be executed by the computer.

Advantages of Assembly Language


i) It is easier to understand and use as compared to machine language.
ii)It is easy to locate and correct errors.
iii) It is modified easily

Disadvantages of Assembly Language


i) Like machine language it is also machine dependent.
ii) Since it is machine dependent therefore programmer Should have the knowledge of the
hardware also.
High Level Languages
High level computer languages give formats close to English language and the purpose of
developing high level languages is to enable people to write programs easily and in their own
native language environment (English). High-level languages are basically symbolic languages
that use English words and/or mathematical symbols rather than mnemonic codes. Each
instruction in the high level language is translated into many machine language instructions thus
showing one-to-many translation
Types of High Level Languages

Many languages have been developed for achieving different variety of tasks, some are fairly
specialized others are quite general purpose.

These are categorized according to their use as

a) Algebraic Formula-Type Processing. These languages are oriented towards the


computational procedures for solving mathematical and statistical problem

Examples are

 BASIC (Beginners All Purpose Symbolic Instruction Code).

Prepared by T.Aruna Sri, Dept of CSE Page 7


Programming With C UNIT 1

 FORTRAN (Formula Translation).


 PL/I (Programming Language, Version 1).
 ALGOL (Algorithmic Language).
 APL (A Programming Language).
b) Business Data Processing:

 These languages emphasize their capabilities for maintaining data processing procedures
and files handling problems. Examples are:
 COBOL (Common Business Oriented Language).
 RPG (Report Program Generator
b) String and List Processing: These are used for string manipulation including search for
patterns, inserting and deleting characters. Examples are:

 LISP (List Processing).


 Prolog (Program in Logic).
Object Oriented Programming Language

In OOP, the computer program is divided into objects. Examples are:

 C++
 Java
e) Visual programming language: these are designed for building Windows-based applications
Examples are:

 Visual Basic
 Visual Java
 Visual C
Advantages of High Level Language

Following are the advantages of a high level language:

 User-friendly
 Similar to English with vocabulary of words and symbols
 Therefore it is easier to learn.
 They require less time to write.
 They are easier to maintain.
 Problem oriented rather than 'machine' based.

Prepared by T.Aruna Sri, Dept of CSE Page 8


Programming With C UNIT 1

 Program written in a high-level language can be translated into many machine language
and therefore can run on any computer for which there exists an appropriate translator.
 It is independent of the machine on which it is used i.e.Programs developed in high level
language can be run on any Computer
Disadvantages of High Level Language
 A high-level language has to be translated into the machine language by a translator and
thus a price in computer time is paid.
 The object code generated by a translator might be inefficient Compared to an equivalent
assembly language program

ALGORITHM:
An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. A
problem in a finite sequence is called an algorithm.

The word ‘Algorithm’ is the name of one Persian author meaning rules of restoration and
reduction. Once the problem is analyzed, its solution is broken into a number of sample steps
Algorithms was developed by an Arab mathematician. It is chalked out step-by-step
approach to solve a given problem. It is represented in an English like language and has some
mathematical symbols like ->, >, <, = etc. To solve a given problem or to write a program you
approach towards solution of the problem in a systematic, disciplined, non-adhoc, step-by-step
way is called Algorithmic approach. Algorithm is a penned strategy(to write) to find a solution.

Properties of an Algorithm
i. Finiteness: An algorithm must always terminate after a finite number of steps.
ii. Definiteness: Each step must be clearly defined that actions carried out must be unambiguous.
iii. Input: Input should be provided at the beginning of algorithm.
iv. Output: Algorithm must produce on or more output.
v. Effectiveness: All the operations defined must be sufficiently basic that they can be done
exactly in finite length of time manually.

Basic Statements Used and Examples


i. Algorithm always begins with the word ‘Start’ and ends with the word ‘Stop’
ii. Step wise solution is written in distinguished steps. This is as shown in example 1.1
Start
Step 1:
Step 2:
Step 3:
.
..
Step n:
End
Example 1.1 Structure of an Algorithm

Prepared by T.Aruna Sri, Dept of CSE Page 9


Programming With C UNIT 1

iii. Input Statement: Algorithm takes one or more inputs to process. The statements used to
indicate the input is Read a or Input b. This is illustrated in example
Let a , b be the names of the Input
Input a or Read a
Input b or Read b
Where a and b are variable names.

iv. Output Statements: Algorithm produces one or more outputs. The statement used to show
the output is output a or print b.
Syntax: Output variable name
Print variable name
For example output a or print a
output b or print b
where a and b are variable names.

v. Assignment Statements: Processing can be done using the assignment statement.


i.e. L.H.S = R.H.S
On the L.H.S is a variable.
While on the R.H.S is a variable or a constant or an expression. The value of the variable,
constant or the expression on the R.H.S is assigned in L.H.S. The L.H.S and R.H.S should be of
the same type. Here ‘ = ’ is called assignment operator.
Let the variables be x, y. The product be z this can be represented by as
Read x, y
Z=x*y

vi. Order in which the steps of an algorithm are executed is divided in to 3 types namely
i) Sequential Order
ii) Conditional Order
iii) Iterative Order

i) Sequential Order
Each step is performed in serial fashion I.e. in a step by step procedure this is illustrated in
example
Task : Write an algorithm to add two numbers.
Step 1 : Start
Step 2 : Read a
Step 3 : Read b
Step 4 : Add a , b
Step 5 : Store in d
Step 6 : Print d
Step 7 : End

ii) Conditional Order


Based on fact that the given condition is met or not the algorithm selects the next step to do. If
statements are used when decision has to be made.
Different format of if statements are available they are

Prepared by T.Aruna Sri, Dept of CSE Page 10


Programming With C UNIT 1

a) Syntax :
if (condition)
Then {set of statements S1}
Here condition means Boolean expressions which evacuates to TRUE or FALSE. If condition is
TRUE then the statements S1 is evaluated. If false S1 is not evaluated Programme skips that
section.
This is illustrated in example 1.6
Task : Write an algorithm to check equality of numbers.
Step 1 : Start
Step 2 : Read a, b
Step 3 : if a = b, print numbers are equal to each other
Step 4 : End

b) Syntax – if else (condition)


if (condition)
Then {set of statements S1}
else
Then {set of statements S2}
Here if condition evaluates to true then S1 is executed otherwise else statements are executed.
This is illustrated in example 1.7
Task : Write an algorithm to print the grade. Step 1 : Start
Step 2 : Read marks
Step 3 : Is marks greater than 60 ?
Step 4 : if step 3 is TRUE
print ’GRADE A’
Step 5 : Other wise
print ’GRADE B’
Step 6 : End
Example 1.7 Format of Conditional order Algorithm

c) Syntax – Nested if else (condition)


If (condition 1)
Then S1
Else
If (condition 2)
Then S2
Else
Then S3
Here if and else condition is in a nested fashion this is more suited for the programs have been
multiple conditions.
This is illustrated in example 1.8

Task : Write an algorithm to find grades of the marks.


Step 1 : Start
Step 2 : Read marks
Step 3 : Is marks greater than 60 ?

Prepared by T.Aruna Sri, Dept of CSE Page 11


Programming With C UNIT 1

Step 4 : if step 3 is TRUE


print ’GRADE A’
Step 5 : else if marks greater than 50 less than 60
print ’GRADE B’
Step 6 : else print ’GRADE C’
Step 7 : End

iii) Iterative Order


Here algorithm repeats the finite number of steps over and over till the condition is not meet.
Iterative operation is also called as looping operation.
Example 1.9 : Add ‘n’ natural numbers till the sum is 5.
Step 1 : Start
Step 2 : set count to 0
Step 3 : add 1 to count
Step 4 : if count is less than 5,
Repeat steps 3 & 4
Step 5 : otherwise print count
Step 6 : End

Flow Charts
The diagrammatic representation of way to solve the given problem is called flow chart. A flow
chart is a graphical or symbolic representation of a process. Each step in the process is
represented by a different symbol and contains a short description of the process step. The flow
chart symbols are linked together with arrows showing the process flow direction.
Algorithm for large problems becomes complex and there by difficult to write the code.
Problem analysts found ‘Flow charts’ an easier way to solve the problem. Here each step is
represented by a symbol and also contains a short description of the process steps within the
symbol.
Flow charts are linked by arrows. The other names of flow chart are flow diagram, process chart,
and business flow diagram etc., most often it is called by name flow chart only. Flow charts can
be used for following aspects
i. Define and analyze
ii. Build step by step picture of a process
iii. To find the areas of improvement in the process

Advantages
i. Communication – it is better way of communicating the logic of a program solution.
ii. Effect analysis – with the help of flow charts problem can be analyze in a effective way
iii. Effective coding – flow charts acts as a blue print during the system analysis
iv. Proper debugging – flow chart helps in debugging process.

Limitations
i. Alterations and modifications: If alterations are required, the flowchart may require re-drawing
completely.

Prepared by T.Aruna Sri, Dept of CSE Page 12


Programming With C UNIT 1

Types of Flowcharts
Flow charts can be broadly classified in to two types
i) system flow charts
These are used by system analyst to describe the data flow and operation in a data processing
cycle. System flow chart defines the broad processing in organizations showing the origin of data
filing structure,processing to be performed and output to be generated.
ii) Program flow chats
Program flow charts are used by programmers. It is used to describe the sequence of operations
and decisions for a particular problem. Generally to solve any of the programs belonging to
COBOL, C, C++, Java. . etc.,program flow charts are used.

Symbols Used in Flowcharts


The flow chart being symbolic representation standard symbols is used for each specific
operation. These symbols are used to represent the sequence of operations and flow of data and
documents required for programming. Flow should be from top to bottom. The most commonly
used symbols are shown in the figure

Examples:

Draw a flowchart to print the sum of two numbers.

Prepared by T.Aruna Sri, Dept of CSE Page 13


Programming With C UNIT 1

Draw a flowchart to print biggest of two numbers.

Program Development Steps


Program Development is a multistep process that requires that we understand the problem,
develop a solution, write the program, and then test it. When we are given the assignment to
develop a program, we will be given a program requirements statement and the design of any
program interfaces. We should also receive an overview of the complete project so that we will
take the inputs we are given and convert them to the outputs that have been specified. This is
known as program design.

Understand the Problem


The first step in solving any problem is to understand it. By reading the requirements statements
carefully, we fully understand it, we review our understanding with the user and the systems
analyst to know the exact purpose.
Develop the solution
Once we fully understand the problem we need to develop our solution. Three tools will help in
this task. 1. Structure chart, 2.Psuedocode &3.Flowcharts. Generally we will use structure chart
and either flowchart or Pseudo code
The structure chart is used to design the whole program .Pseudo code and flowcharts are used to
design the individual parts of the program.

Prepared by T.Aruna Sri, Dept of CSE Page 14


Programming With C UNIT 1

Structure chart: A structure chart, also known as hierarchy chart, shows the functional flow
through our program. The structure chart shows how we are going to break our program into
logical steps each step will be a separate module. The structure chart shows the interaction
between all the parts (modules) of our program.
We can use flowchart or pseudo code to complete the design of your program will depend on
experience and difficulty of the program your designing.
Write the program
When we write a program, we start with the top box on the structure chart and work our way to
the bottom. This is known as top-down implementation. We will write the programs by using
structure chart and flowchart or pseudo code.
Test the Program
Program testing can be a very tedious and time- consuming part of program development. As the
programmer we are responsible for completely testing our program. In large-development
projects test engineers are responsible for testing to make sure all the programs work together.
There are 2 types of testing.
1. Black box testing: This is done by the system test engineer and the user. Black box
testing is the programs are tested without knowing what is inside it, with out knowing
how it works. Black box test plans are developed by looking only the requirements
statement. The test engineer uses these requirements to develop test plans.
2. White box testing: This is the responsibility of the programmer. White box testing
assumes that the tester knows everything about the program.

Introduction to c
History of C
“C” is a programming language developed at AT & T Bell Laboratories of USA in 1972. It was
developed Dennis Ritche in late 1970‟s. it began to replace the more familiar languages of that
time like PL/1, ALGOL etc.
 “C” became popular because of its reliability, simple and easy to use
 It was friendly capable and reliable
 ALGOL 60 was developed and did not become popular because it was too general and
too abstract.
 They developed “CPU” (Combined Programming Language)
 Next as it could not come up to make ALGOL 60 better one they moved to “BCPL”
(Basic Combines Programming Language. Developed by martin Richard Cambridge
university)
 At the same time a language called “B” written by ken Thompson at AT & T‟S. Bell
laboaratories as a further simplification of BCPL.
 “C” s compactness and coherence is mainly due to it‟s one man language. Ex- LISP,
AASCA

Prepared by T.Aruna Sri, Dept of CSE Page 15


Programming With C UNIT 1

Features of C:

1. General Purpose Programming Language: it is general purpose programming language. It


is usually called “system programming language” but equally suited to writing a variety of
applications.
2. Middle Level: As a middle level language it bridges elements of high level language with
the functionality of assembly language.
3. Structured Programming: C is very suited for structured programming. The programmers
can easily divide a problem into a number of modules or functions.
4. Simplicity: C is simple to use because of its structured approach. It has a wide collection of
inbuilt functions, keywords, operators and data types.
5. Portability: This refers to the ability of a program to run in different environments. With the
availability of compilers for almost all operating systems and hardware platforms, it is easy
to write code on one system which can be easily ported to another.
6. Wide Acceptability: C is widely popular in the software industry. Its importance is not
entirely derived from its use as primary development language but also because of its use as
an interface language to some of the visual languages.
7. Flexibility: C Language combines the convenience and portable nature of a high level
language with the flexibility of a low level language. It can be interfaced readily to other
programming languages.
8. Efficient Compilation and Execution: The process of compilation and execution of
programs is quite fast in C Language as compared to other languages like BASIC
(Beginner’s All purpose Symbolic Instruction Code) and FORTRAN
FORmula TRANslator).
9. Modularity: C Language programs can be divided into small modules with the help of
functions which help in increasing understanding of the programs.
10. Clarity: The features like keywords, in-built functions and structures help to improve the
clarity and hence understanding of the program.
11. High Availability: The software of C Language is readily available in market and can be
easily installed on the computer.
12. Easy Debugging: The syntax errors can be easily detected by the C compiler. The error is
displayed with line number of the code and the error message.
13. Memory Management: Various memory management in-built functions are available in C
language which helps to save memory and hence improve efficiency of the program. e.g.
malloc(),alloc() and calloc().
14. Recursion: Recursion is a technique in which the function calls itself again and again until a
condition is achieved.
15. Rich set of Library Functions: C has a rich set of library functions. These are the functions
that provide readymade functionality to the users. It also supports graphic programming.

Advantages:
1. Modularity
modularity is one of the important characteristics of C. we can split the C program into no. of
modules instead of repeating the same logic statements (sequentially). It allows reusability of
modules.

Prepared by T.Aruna Sri, Dept of CSE Page 16


Programming With C UNIT 1

2. Middle level language:


As a middle level language C combines both the advantages of low level and high level
languages. (arrays,pointers etc).
3. General purpose programming language:
C can be used to implement any kind of applications such as math’s oriented, graphics,
business oriented applications.
4. Portability:
we can compile or execute C program in any operating system(unix,dos,windows).
5. Powerful programming language:
C is very efficient and powerful programming language, it is best used for data structures and
designing system software.

Structure of C program
The program written in C language follows this basic structure. The sequence of sections should
be as they are in the basic structure. A C program should have one or more sections but the
sequence of sections is to be followed.

1. Documentation section
2. Linking section
3. Definition section
4. Global declaration section
5. Main function section
{
Declaration section
Executable section
}
6. Sub program or function section

1. DOCUMENTATION SECTION : comes first and is used to document the use of logic or
reasons in your program. It can be used to write the program's objective, developer and logic
details. The documentation is done in C language with /* and */ . Whatever is written
between these two are called comments.

2. LINKING SECTION : This section tells the compiler to link the certain occurrences of
keywords or functions in your program to the header files specified in this section.
e.g. #include <stdio.h>

3. DEFINITION SECTION : It is used to declare some constants and assign them some value.
e.g. #define MAX 25
Here #define is a compiler directive which tells the compiler whenever MAX is found in
the program replace it with 25.

Prepared by T.Aruna Sri, Dept of CSE Page 17


Programming With C UNIT 1

4. GLOBAL DECLARATION SECTION : Here the variables which are used through out the
program (including main and other functions) are declared so as to make them global(i.e
accessible to all parts of program)
e.g. int i; (before main())

5. MAIN FUNCTION SECTION : It tells the compiler where to start the execution from
main()
{
point from execution starts
}

main function has two sections


1. declaration section : In this the variables and their data types are declared.
2. Executable section : This has the part of program which actually performs the task we
need.

6. SUB PROGRAM OR FUNCTION SECTION : This has all the sub programs or the
functions which our program needs.

Example:
//Area of rectangle -comments-Documentation
#include<stdio.h> //header file-linker
#define pi 3.14 //symbolic constants -Definition
float r=3.2; //Global declaration
int main( ) //main section
{
float h,cyl; //declaration
area();// Executable Statement -function call
printf("enter h value\n"); // Executable Statement
scanf("%f",&h); // Executable Statement
cyl=pi*r*r*h; //Executable Statement
printf("volume of cylinder =%f\n",cyl); //Executable Statement
return 0;
}//end of main()
area() // subprogram section
{
float ar; //declaration
ar=pi*r*r; //statements
printf("Area of circle is %f\n",ar);
}//end of sub program section

Creating and Running Programs:


Computer hardware understands a program only if it is coded in its machine language. It is the
job of the programmer to write and test the program .
There are four steps in this process:
1.Writing and Editing the program

Prepared by T.Aruna Sri, Dept of CSE Page 18


Programming With C UNIT 1

2.Compiliing the program


3.Linking the program with the required library modules
4.Executing the program.

Writing and Editing Programs

The software used to write programs is known as a text editor. A text editor helps us enter,
change, and store character data. Depending on the editor on our system, we could use it to write
letters, create reports, or write programs. The main difference between text processing and
program writing is that programs are written using lines of code, while most text processing is
done with character and lines.

Text editor is a generalized word processor, but it is more often a special editor included with the
compiler. Some of the features of the editor are search commands to locate and replace
statements, copy and paste commands to copy or move statements from one part of a program to
another, and formatting commands that allow us to set tabs to align statements.After completing
a program, we save our file to disk. This file will be input to the compiler; it is known as a
source file.

Compiling Programs:
The code in a source file stored on the disk must be translated into machine language ,This is the
job of the compiler. The c compiler is two separate programs. the preprocessor and the
translator.
The preprocessor reads the source code and prepares it for the translator. While
preparing the code ,it scans for special instructions known as preprocessor commands. These
commands tell the preprocessor to look for special code libraries, make substitutions in the code
,and in other ways prepare the code for translation into machine language. The result of
preprocessing is called the translation unit.

Prepared by T.Aruna Sri, Dept of CSE Page 19


Programming With C UNIT 1

After the preprocessor has prepared the code for compilation, the translator does the actual work
of converting the program into machine language. The translator reads the translation unit and
writes the resulting object module to a file that can then be combined with other precompiled
units to form the final program. An object module is the code in machine language. The output
of the compiler is machine language code, but it is not ready to run; that is ,it is not executable
because it does not have the required C and other functions included.

Linking Programs:
A C program is made up of many functions. We write some of these functions, and they are a
part of our source program. There are other functions, such as input/output processes and,
mathematical library functions, that exist elsewhere and must be attached to our program. The
linker assembles all of these functions, ours and systems into our final executable program.

Executing Programs:
Once program has been linked, it is ready for execution. To execute a program we use an
operating system command, such as run, to load the program into primary memory and execute
it. Getting the program into memory is the function of an operating system program known as
the loader. It locates the executable program and reads it into memory. When everything is
loaded, the program takes control and it begins execution.
In a typical program execution, the reads data for processing ,either from the user or from
a file. After the program processes the data, it prepares the output. at output can be to the user’s
monitor or to a file. When the program has finished its job, it tells the operating system ,which
then removes the program from memory.

Preprocessing, Compiling and Linking

There are three basic phases that are important when programming in C and using a C compiler.
The phases are called preprocessing,compiling, and linking. When programming in other
languages, only two phases are required: compiling and linking. An C input file is first passed
to a preprocessing program called the preprocessor. The output of the preprocessor is passed to
the true-C compiler. The output of the C compiler is then fed into a linker program. The linker
finally produces an executable form of your program. The following diagram demonstrates a C
program one.c being converted into an executable program.

one.c --> PREPROCESSOR -> tmp.c(temporary) -> COMPILER -> one.obj ->
LINKER -> one.exe (final Executable)

Prepared by T.Aruna Sri, Dept of CSE Page 20


Programming With C UNIT 1

Preprocessing Phase:

A C preprocessor is a program that accepts C code with preprocessing statements and produces a
pure form of C code that contains no preprocessing statements. A preprocessor basically reads
line by line from the input and replicates the line to the output. If the line is a preprocessing
statement, then it performs the preprocessing directives. All preprocessing statements in C begin
with the # symbol and are at the beginning of a line. The operations of taking the input file and
generating the output file, pre-processed file, is called pre-processing.

Input File(ie One.c) ---> Preprocessor --> Output File (ie tmp.c )

The output file is then fed as input into the true C compiler. If there are no preprocessing
directives in the original C input file, then the output file will look identical to the input file. Also
called preprocessor directives, preprocessor statements are special statements that tell the
preprocessor to perform special set of operations.

The main two preprocessor statements are the #define and the #include statements. Preprocessor
statement must be on independent lines. Two preprocessor statements cannot be on the same
line.

The #define preprocessing statement tells the preprocessor to generate a replacement sequence
of characters for a given symbol.

The next example defines four preprocessor symbols. The preprocessor first starts reading the
first line of the input file. As this line is a comment, no output is generated. The next statement is
the first #define statement. This statement tells the preprocessor that, any time in the future that
it reaches a symbol called "Print", it will replace the symbol with the sequence "int printf(...)".
The next define statement directs the preprocessor to equate the symbol "Ret" with the sequence
"return 0". The third define statement equates the symbol "BEGIN" with "{". The final define
statement equates "END" with the "}". The next line beyond the define statements is a blank line.
This is the first generating line of output : a blank line is sent out to the output file.

Box #1: Example Input/Output to a preprocessor

Input To Preprocessor

// This is a test Example with Preprocessing

#define Print printf(...)

#define Ret return 0

#define BEGIN {

#define END }

Prepared by T.Aruna Sri, Dept of CSE Page 21


Programming With C UNIT 1

Print;

int main(void)

BEGIN

printf("Hello World"); Ret;

END

Output Of Preprocessor:

// This is a test Example with Preprocessing

printf(...);

int main(void)

printf("Hello World"); return 0;

The next statement that is read is a "Print;". Notice that at this point the preprocessor has already
been told that whenever it reaches a symbol "Print" to generate an output of "printf(...). The final
";" is just copied to the output. So, this statement generates an output of "printf(char *,...);" The
line "int main()" is copied to the output as usual. The next line " BEGIN", produces an out put of
" {", since the preprocessor has been previously told to generate a different sequence of output
when it reaches a symbol "BEGIN". The next statement " printf("Hello World");" is copied to the
output unchanged. The " Ret;" generates the output " return 0;". The final " END" translates to "
}".

The #include preprocessing statement is used to tell the preprocessor to preprocess another file
before continuing on. In the next example Box 2, the first file myfile contains the declaration of
printf. The second file will use the include preprocessor statement to include the contents of the
file myfile in the output. The input C File is passed to the preprocessor. The preprocessor skips
generating output for the first line as it is a comment line. The next line it reads is the
preprocessing directive "#include <MyFile>". The preprocessor stops processing the current
input C file and opens the file "MyFile" to continue processing. Other than opening the file for
new input, the preprocessor does not generate any output. Notice that the next line that is read by
the preprocessor is the comment "//This is the contents of the file". The statement "int printf(char
*,...); is copied to the output without modification. As this is the last line of the file "MyFile", the
preprocessor closes the the file, and resumes preprocessing of the original source C file. The next

Prepared by T.Aruna Sri, Dept of CSE Page 22


Programming With C UNIT 1

line that is read by the preprocessor is the empty line. This is copied to the output as usual. The
preprocessing continues until the rest of the file is sent to the output.

Box #2: Example of Input/Output of Preprocessor

Contents of File MyFile

// This is the contents of MyFile.h

int printf(...);

Input C File for Preprocessor

#include <MyFile>

int main(void)

printf("Another Boring Hello\n");

return 0;

Output from Preprocessor

int printf(...)

int main(void)

printf("Another Boring Hello\n");

return 0;

Most programmers tend to forget the exact declaration "int prinf(...);". There are many other
functions other than printf that are part of the standard input/output libraries of C. Again like
printf, they are not part of the C language. All these other functions have to be declared too.
Declaring all the functions that can be used is often too tiring to write every time one writes a C
program. Instead all the declaration for standard input and output is declared in a single file
called stdio.h. The following program, Box #3, uses the #include statement with filestdio.h. The
file is referred to as the standard input and output header file. It is called a header file as most

Prepared by T.Aruna Sri, Dept of CSE Page 23


Programming With C UNIT 1

programmers place the #include statement at the top of their programs. Header files usually
have a file extension of .h.

Box #3: Example Program using stdio.h header file.

#include <stdio.h>

int main(void)

printf("Hello World\n"); // Hello World Comment

return 0;

Compile Phase:

This is the true C compiler. The C compiler accepts a preprocessed output file from the
preprocessor and produces a special file called an object file. This object file contains machine
code generated from the program you wrote in your original C file. It does not as of yet contain
code for functions such as printf. Since the code for printf is not in your code, the object file
contains symbol printf. Usually a special file extension(obj) is given to an object file.
Preprocessor Output File ---> True C-Compiler ---> Object File
Think of an object file as a partially complete program with missing blocks of code(ie the code
for printf). During the next phase called the Link Phase, it is the linker program that is
responsible to find the missing code "printf" and link it(bind it) to the object file generated by the
compiler.The compiler also removes all comments from the input file.

Link Phase:
The link phase is implemented by the linker. The linker is a process that accepts as input object
files and libraries to produce the final executable program. Libraries contain object code. This
object code in turn contains functions. In the link phase the object code from the compile phase
is bound to the missing function code such as printf. The function printf is located in the standard
input and output libraries. The final executable now contains all the necessary code for
execution.

Object File ----> Linker(Searches Libraries) ------> Exe File

Different types of errors:


Error is a mistake or bug, which can be associated with programmer in program, common
programming errors in C can be classified into 3 types:
1. compilation errors.(syntax errors)
2. linker errors.
3. logical errors.

Prepared by T.Aruna Sri, Dept of CSE Page 24


Programming With C UNIT 1

Compilation(syntax ) errors:
These are raised when we compile the program and can be located and corrected easily. Most
common compilation or syntax errors are.
 Undefined variable
 Redeclaration of variable
 Unterminated string character
 Missing semicolon ;
 Function call missing ( ,;”)
 Function should have prototype.

Compiler errors are generated whenever either the syntax of the C language is not met or
undefined symbols are met in the code. The next program in Box #5 has three errors which are
explained with comments.

Box #5: Compiler Syntax Errors

#include <stdio.h>

int main(void)

printf("this is a test") // not terminating semicolon -> printf("this is a test");

printf("This is a test); // no closing double quotes -> printf("This is a test");

return0; // unknown symbol return0 -> return 0;


)

Linker errors:

Linker Errors are generated when linker finds missing symbol references in the object code
generated by the compiler. As an example, if the standard input/output library is missing and the
object code contains a reference to the printf function, the linker will generate an error stating
"Unresolved external reference to _printf".

In the next program in Box #6, a missing _main symbol error is generated. As all programs
must have a main definition ( a body for the main code) to execute. It is the linker that notices
that the main function is missing.

Box #6: Linker Error for Missing main function

#include <stdio.h>

Prepared by T.Aruna Sri, Dept of CSE Page 25


Programming With C UNIT 1

int mmain(void) // definition of mmain function - not main function

printf("Hello World\n");

return 0;

The next class of errors are called logical-errors. These errors are errors in the design of the
program. The next program(Box #7) is supposed to print out hello world, but the programmer
miswrote the program.

The program must be linked to the ‘C’ library. If it fails in such case these errors are raised .
most common errors are:
 Unable to link cos.obj
 Undefined symbol

Logical ( run time) errors:


These are raised because of the due to logical inefficiency. We can know them when program
gets executed. It is very difficult to locate them, most common logical errors are:
 Divide by zero
 Floating point error
 Null value
 Garbage result in printing.

It is very important to know the different phases as many errors are directly related to them. The
errors generated can be preprocessing errors, compiler errors, linker errors, logical errors, and
run-time errors.

Box #7: Logical Error Example

#include <stdio.h>

int main(void)

printf("Hello ");

return 0; // Program finishes before "World" is printed.

printf("World\n");

Prepared by T.Aruna Sri, Dept of CSE Page 26


Programming With C UNIT 1

return 0;

The last class of errors are those programs that execute and fail. These are called run-time
errors. The next program(Box #8) will generate a divide by zero error during execution of the
program.

Box #8: Run-Time Error Example

#include <stdio.h>

int main(void)

printf("Hello World\n");

return 13/(12-12); // program generates a division by zero error

Preprocessing errors:

A common preprocessor error is not finding the include file in the include statement. Either the
filename is spelled wrong or the preprocessor has the wrong directory to search for that file.

Sometimes a #define statement might subtly lead to an compiler error as in the following(Box
#4). The programmer defines the symbol "PRINT" for the sequence of characters "printf // This
is a comment". In the body of the main function, the "PRINT("Hello World");" is replaced with
"printf // this is a comment ("Hello World");". Since everything after the "//" is considered a
comment. The output that is generated for that line by the preprocessor is "printf // ...". The
preprocessed file is then sent to the compiler, which then generates a compile time error of
"Error: Unexpected return after function call printf"!

Box #4: Preprocessing Caused Compiler Error

Input C File To Preprocessor

int printf(...);

#define PRINT printf // This is a comment

Prepared by T.Aruna Sri, Dept of CSE Page 27


Programming With C UNIT 1

int main(void)

PRINT("Hello World");

return 0;

Output of Preprocessor

int printf(...);

int main(void)

printf // This is a comment ("Hello World");

return 0;

Identifier:
In C programming, identifiers are names given to C entities, such as variables, functions,
structures etc. Identifier are created to give unique name to C entities to identify it
during the execution of program.

Ex: int sum; int sec_num;

Here, sum is a identifier which denotes a variable of type integer. Similarly, sec_num is
another identifier, which denotes another variable of type integer.
Rules for writing identifier
 An identifier can be composed of letters (both uppercase and lowercase letters),
digits and underscore '_' only.
 The first letter of identifier should be either a letter or an underscore. But, it is
discouraged to start an identifier name with an underscore though it is legal. It is
because, identifier that starts with underscore can conflict with system names.
In such cases, compiler will complain about it. Some system names that start with
underscore are _fileno, _iob, _wfopen etc.

Prepared by T.Aruna Sri, Dept of CSE Page 28


Programming With C UNIT 1

 There is no rule for the length of an identifier. However, the first 31 characters of an
identifier are discriminated by the compiler. So, the first 31 letters of two identifiers
in a program should be different.

Data Types in C
Data type in C defines the amount of storage allocated to variables ,the values that they can
accept ,and the operation that can be performed on those variables.
C is rich in data types. The verity of data type allow the programmer to select appropriate data
type to satisfy the need of application as well as the needs of different machine.

Data types in sizes:

Prepared by T.Aruna Sri, Dept of CSE Page 29


Programming With C UNIT 1

Variable:
 A variable is a name for a location in memory used to store a data value.
 We use variables to save and restore values or the results of calculations.
 The programmer has to tell Java what type of data will be store in the variable’s memory
location. Its type cannot change.
 During the program execution the data saved in the memory location can change; hence the
term “variable”.

Rules for naming C variable:


 Variable name must begin with letter or underscore.
 Variables are case sensitive
 They can be constructed with digits, letters.
 No special symbols are allowed other than underscore.
 sum, height, _value are some examples for variable name

Declaring & initializing C variable:

 Variables should be declared in the C program before to use.


 Memory space is not allocated for a variable while declaration. It happens only on variable
definition.
 Variable initialization means assigning a value to the variable.

S.No Type Syntax Example


1 Variable declaration data_type variable_name; int x, y, z; char flat, ch;

Variable data_type variable_name = int x = 50, y = 30; char flag = ‘x’,


2
initialization value; ch=’l’;

There are three types of variables in C program They are,


1. Local variable
2. Global variable
3. Environment variable

Difference between variable declaration & definition in C:


S.no Variable declaration Variable definition
Declaration tells the compiler about data type and
1 Definition allocates memory for the variable.
size of the variable.
Variable can be declared many times in a It can happen only one time for a variable in a
2
program. program.
The assignment of properties and identification to
3 Assignments of storage space to a variable.
a variable.

Prepared by T.Aruna Sri, Dept of CSE Page 30


Programming With C UNIT 1

There are two types of variables in C program They are,


Local variable
Global variable

1. Example program for local variable in C:

 The scope of local variables will be within the function only.


 These variables are declared within the function and can’t be accessed outside the function.
 In the below example, m and n variables are having scope within the main function
only. These are not visible to test function.
 Like wise, a and b variables are having scope within the test function only. These are not
visible to main function.

#include<stdio.h>
void test();
int main()
{
int m = 22, n = 44;
// m, n are local variables of main function
/*m and n variables are having scope within this main function only.
These are not visible to test funtion.*/
/* If you try to access a and b in this function, you will get 'a' undeclared and 'b' undeclared
error */
printf("\nvalues : m = %d and n = %d", m, n);
test();
}
void test()
{
int a = 50, b = 80;
// a, b are local variables of test function
/*a and b variables are having scope within this test function only.These are not visible to
main function.*/
/* If you try to access m and n in this function, you will get 'm' undeclared and 'n' undeclared
error */
printf("\nvalues : a = %d and b = %d", a, b);
}
Output:
values : m = 22 and n = 44
values : a = 50 and b = 80

2. Example program for global variable in C:

 The scope of global variables will be throughout the program. These variables can be
accessed from anywhere in the program.
 This variable is defined outside the main function. So that, this variable is visible to main
function and all other sub functions.

Prepared by T.Aruna Sri, Dept of CSE Page 31


Programming With C UNIT 1

#include<stdio.h>
void test();
int m = 22, n = 44;
int a = 50, b = 80;
int main()
{
printf("All variables are accessed from main function");
printf("\nvalues : m= %d : n= %d : a= %d : b= %d",m,n,a,b);
test();
}
void test()
{
printf("\n\nAll variables are accessed from" \ " test function");
printf("\nvalues : m= %d : n= %d : a= %d : b= %d",m,n,a,b);
}
Output:
All variables are accessed from main function
values : m = 22 : n = 44 : a = 50 : b = 80
All variables are accessed from test function
values : m = 22 : n = 44 : a = 50 : b = 80

Constants
 C Constants are also like normal variables. But, only difference is, their values can not be
modified by the program once they are defined.
 Constants refer to fixed values. They are also called as literals
 Constants may be belonging to any of the data type.
 Syntax:
 const data_type variable_name; (or) const data_type *variable_name;

Types of C constants:

Prepared by T.Aruna Sri, Dept of CSE Page 32


Programming With C UNIT 1

S.no Constant type data type Example


int 53, 762, -478 etc
unsigned int 5000u, 1000U etc
1 Integer constants
long int 483,647
long long int 2,147,483,680
float 10.456789
2 Real or Floating point constants
doule 600.123456789
3 Octal constant int 013 /* starts with 0 */
4 Hexadecimal constant int 0×90 /* starts with 0x */
5 character constants char ‘A’ , ‘B’, ‘C’
6 string constants char “ABCD” , “Hai”
Rules for constructing C constant:

1. Integer Constants in C:
 An integer constant must have at least one digit.
 It must not have a decimal point.
 It can either be positive or negative.
 No commas or blanks are allowed within an integer constant.
 If no sign precedes an integer constant, it is assumed to be positive.
 The allowable range for integer constants is -32768 to 32767.

2. Real constants in C:
 A real constant must have at least one digit
 It must have a decimal point
 It could be either positive or negative
 If no sign precedes an integer constant, it is assumed to be positive.
 No commas or blanks are allowed within a real constant.

3. Character and string constants in C:


 A character constant is a single alphabet, a single digit or a single special symbol enclosed
within single quotes.
 The maximum length of a character constant is 1 character.
 String constants are enclosed within double quotes.

How to use constants in a C program?


 We can define constants in a C program in the following ways.
 By “const” keyword
 By “#define” preprocessor directive
 Please note that when you try to change constant values after defining in C program, it will
through error.

Prepared by T.Aruna Sri, Dept of CSE Page 33


Programming With C UNIT 1

1. Example program using const keyword in C:


#include <stdio.h>
void main()
{
const int height = 100; /*int constant*/
const float number = 3.14; /*Real constant*/
const char letter = 'A'; /*char constant*/
const char letter_sequence[10] = "ABC"; /*string constant*/
const char backslash_char = '\?'; /*special char cnst*/
printf("value of height : %d \n", height );
printf("value of number : %f \n", number );
printf("value of letter : %c \n", letter );
printf("value of letter_sequence : %s \n", letter_sequence);
printf("value of backslash_char : %c \n", backslash_char);
}
Output:
value of height : 100
value of number : 3.140000
value of letter : A
value of letter_sequence : ABC
value of backslash_char : ?

2. Example program using #define preprocessor directive in C:


#include <stdio.h>
#define height 100
#define number 3.14
#define letter 'A'
#define letter_sequence "ABC"
#define backslash_char '\?'
void main()
{
printf("value of height : %d \n", height );
printf("value of number : %f \n", number );
printf("value of letter : %c \n", letter );
printf("value of letter_sequence : %s \n", letter_sequence);
printf("value of backslash_char : %c \n", backslash_char);
}
Output:
value of height : 100
value of number : 3.140000
value of letter : A
value of letter_sequence : ABC
value of backslash_char : ?

Prepared by T.Aruna Sri, Dept of CSE Page 34


Programming With C UNIT 1

Keywords
 Key words or Reserve words of the C language are the words whose meaning is already
defined and explained to the C language compiler. Therefore Reserve words can not be used
as identifiers or variable names. They should only be used to carry the pre-defined meaning.
For example int is a reserve word.
It indicates the data type of the variable as integer. Therefore it is reserved to carry
the specific meaning.
 keywords are also called ‘Reserved words’.
 Keywords are the words whose meaning has already been explained to the C compiler and
their meanings cannot be changed.
 Keywords serve as basic building blocks for program statements.
 Keywords can be used only for their intended purpose.
 Keywords cannot be used as user-defined variables.
 All keywords must be written in lowercase
 Any attempt to use it other than the intended purpose will generate a compile time error.
 C language has 32 keywords. Following are some of them

Identifier keyword
Identifiers are names that are given to various C take some reserved word called keyword,
program elements, such as variable, function they have predefine meaning in C.
and arrays.
Identifiers consist of letters and digits. Keyword consist only letter.
Identifier’s first character must be a letter. Keyword’s all character is letter.
Identifiers Upper and lowercase letter is use. Keywords are all lowercase.
Upper and lowercase are not equivalent. Upper and lowercase are also not equivalent.
Like: X, sum_5, _weather etc. Like: auto, short, long etc.
But 4th is not identifier cause identifier first
character must a letter.

Prepared by T.Aruna Sri, Dept of CSE Page 35


Programming With C UNIT 1

Operators in c:
C has a large number of built in operators. An operator is a symbol which acts on operands to
produce certain result as output. The data items on which operators act upon are called
‘operands’ For example in the expression a+b; + is an operator, a and b are operands. The
operators are fundamental to any mathematical computations.
Based on the number of operands the operator acts upon, Operators can be classified as follows:
 Unary operators: acts on a single operand.
For example: unary minus(-5, -20, etc), address of operator (&a)
 Binary operators: acts on two operands. Ex: +, -, %, /, *, etc
 Ternary operator: acts on three operands. The symbol ?: is called ternary operator in C
language.
Usage: big= a>b?a:b; i.e if a>b,then big=a else big=b.
Based on the functions, operators can be classified as given below in the

1. Arithmetic Operators:
These operators are used to perform mathematical calculations like addition, subtraction,
multiplication, division and modulus.

S.no Operator Operation

1 + Addition

2 - Subtraction

3 * multiplication

4 / Division

Prepared by T.Aruna Sri, Dept of CSE Page 36


Programming With C UNIT 1

5 % Modulus

Example program for C arithmetic operators:

# include <stdio.h>

int main()

int a=40,b=20, add,sub,mul,div,mod;

add = a+b;

sub = a-b;

mul = a*b;

div = a/b;

mod = a%b;

printf("Addition of a, b is : %d\n", add);

printf("Subtraction of a, b is : %d\n", sub);

printf("Multiplication of a, b is : %d\n", mul);

printf("Division of a, b is : %d\n", div);

printf("Modulus of a, b is : %d\n", mod);

Output:

Addition of a, b is : 60
Subtraction of a, b is : 20
Multiplication of a, b is : 800
Division of a, b is : 2
Modulus of a, b is : 0

2. Assignment operators:

Prepared by T.Aruna Sri, Dept of CSE Page 37


Programming With C UNIT 1

The values for the variables are assigned using assignment operators. For example, if the value
10 is to be assigned for the variable sum, it can be done like below.
sum = 10;
Below are some of other assignment operators:
Operator Example Explanation

Simple operator = sum = 10 Value 10 is assigned to variable sum

Compound assignment operator += sum+=10 This is same as sum = sum+10

-= sum – = 10 This is same as sum = sum – 10

*= sum*=10 This is same as sum = sum*10

/+ sum/=10 This is same as sum = sum/10

%= sum%=10 This is same as sum = sum%10

&= sum&=10 This is same as sum = sum&10

^= sum^=10 This is same as sum = sum^10

1 # include <stdio.h>

2 int main()

3 {

4 int Total=0,i;

5 for(i=0;i<10;i++)

6 {

7 Total+=i; // This is same as Total = Toatal+i

8 }

Prepared by T.Aruna Sri, Dept of CSE Page 38


Programming With C UNIT 1

9 printf("Total = %d", Total);

10 }

Output:

Total = 45

3. Relational operators:

These operators are used to find the relation between two variables. That is, used to
compare the value of two variables.

Example program for relational operators:

1 #include <stdio.h>

2 int main()

3 {

4 int m=40,n=20;

5 if (m == n) {

6 printf("m and n are equal");

Prepared by T.Aruna Sri, Dept of CSE Page 39


Programming With C UNIT 1

7 }

8 else {

9 printf("m and n are not equal");

10 }

11 }

Output:

m and n are not equal

4. Logical operators:
These operators are used to perform logical operations on the given two variables.

Meaning of
Operator Operator Example

Logial If c=5 and d=2 then,((c==5) &&


&& AND (d>5)) returns false.

Logical If c=5 and d=2


|| OR then, ((c==5) || (d>5)) returns true.

Logical
! NOT If c=5 then, !(c==5) returns false.

Example program for logical operators:

1 #include <stdio.h>

2 int main()

3{

4 int m=40,n=20;

5 if (m>n && m !=0) {

6 printf("m is greater than n and not equal to 0");

Prepared by T.Aruna Sri, Dept of CSE Page 40


Programming With C UNIT 1

7 }

8}

Output:

m is greater than n and not equal to 0

5. Bit wise operators:


These operators are used to perform bit operations on given two variables.

Operators Meaning of operators

& Bitwise AND

| Bitwise OR

^ Bitwise exclusive OR

~ Bitwise complement

<< Shift left

>> Shift right

Operator Description Example

(A & B) will give 12 which is 0000


& Binary AND Operator copies a bit to the result if it exists in both operands.
1100

(A | B) will give 61 which is 0011


| Binary OR Operator copies a bit if it exists in either operand.
1101

(A ^ B) will give 49 which is 0011


^ Binary XOR Operator copies the bit if it is set in one operand but not both.
0001

Prepared by T.Aruna Sri, Dept of CSE Page 41


Programming With C UNIT 1

(~A ) will give -61 which is 1100


Binary Ones Complement Operator is unary and has the effect of 'flipping'
~ 0011 in 2's complement form due
bits.
to a signed binary number.

Binary Left Shift Operator. The left operands value is moved left by the A << 2 will give 240 which is 1111
<<
number of bits specified by the right operand. 0000

Binary Right Shift Operator. The left operands value is moved right by the A >> 2 will give 15 which is 0000
>>
number of bits specified by the right operand. 1111

#include <stdio.h>

main()
{

unsigned int a = 60; /* 60 = 0011 1100 */


unsigned int b = 13; /* 13 = 0000 1101 */
int c = 0;

c = a & b; /* 12 = 0000 1100 */


printf("Line 1 - Value of c is %d\n", c );

c = a | b; /* 61 = 0011 1101 */
printf("Line 2 - Value of c is %d\n", c );

c = a ^ b; /* 49 = 0011 0001 */
printf("Line 3 - Value of c is %d\n", c );

c = ~a; /*-61 = 1100 0011 */


printf("Line 4 - Value of c is %d\n", c );

c = a << 2; /* 240 = 1111 0000 */


printf("Line 5 - Value of c is %d\n", c );

c = a >> 2; /* 15 = 0000 1111 */


printf("Line 6 - Value of c is %d\n", c );
}

Output:
Line 1 - Value of c is 12
Line 2 - Value of c is 61
Line 3 - Value of c is 49
Line 4 - Value of c is -61
Line 5 - Value of c is 240
Line 6 - Value of c is 15

Prepared by T.Aruna Sri, Dept of CSE Page 42


Programming With C UNIT 1

6. Conditional operators:
Conditional operators return one value if condition is true and returns other value is condition
is false.
This operator is also called as ternary operator.

Syntax : (Condition? true_value: false_value);

Example : (A > 100 ? 0 : 1);

Here, if A is greater than 100, 0 is returned else 1 is returned. This is equal to if else
conditional statements.

Example program for conditional/ternary operators:

1 #include <stdio.h>

2 int main()

3{

4 int x=1, y ;

5 y = ( x ==1 ? 2 : 0 ) ;

6 printf("x value is %d\n", x);

7 printf("y value is %d", y);

8}

Output:

x value is 1
y value is 2

7. Increment and decrement operators:

These operators are used to either increase or decrease the value of the variable by one.

Syntax : ++var_name; (or)

var_name++; (or)

– - var_name; (or)

Prepared by T.Aruna Sri, Dept of CSE Page 43


Programming With C UNIT 1

var_name- -;

Example : ++i, i++, - -i, i- -

Example program for increment operators:

//Example for increment operators

2 #include <stdio.h>

3 int main()

4 {

5 int i=1;

6 while(i<10)

7 {

8 printf("%d\n",i);

9 i++;

10 }

11 }

Output:

1
2
3
4
5
6
7
8
9

Prepared by T.Aruna Sri, Dept of CSE Page 44


Programming With C UNIT 1

Example program for decrement operators:

1. //Example for decrement operators

2. #include <stdio.h>

3. int main()

4. {

5. int i=20;

6. while(i>10)

7. {

a. printf("%d\n",i);

b. i--;

8. }

9. }

Output:

20
19
18
17
16
15
14
13
12
11

Prepared by T.Aruna Sri, Dept of CSE Page 45


Programming With C UNIT 1

8. Special Operators:

Below are some of special operators that the C language offers.

S.no Operators Description

This is used to get the address of the variable.


1 &
Example: &a will give address of a.

This is used as pointer to a variable.


2 *
Example: * a where, * is pointer to the variable a.

This gives the size of the variable.


3 Size of ()
Example: size of (char) will give us 1.

This is ternary operator and act exactly as if … else


4 ternary
statement.

Type cast is the concept of modifying variable from


5 Type cast
one data type to other.

Do you know difference between pre/post increment and pre/post decrement operators?

That means, i++ and ++i i– and –i.

Below table will explain you how these operators to be used in a C program.

S.no Operator Description

while(i++ < 5) The value of i is compared with 5, before incrementing i


1
value by 1.

2 while(++i < 5) The value of i is incremented by 1, before comparing with 5.

Prepared by T.Aruna Sri, Dept of CSE Page 46


Programming With C UNIT 1

while(i – - < The value of i is compared with 5, before decrementing i


3
5) value by 1.

while(- - i <
4 The value of i is decremented by 1, before comparing with 5.
5)

Example program for pre – increment operators:

1 //Example for increment operators

3 #include <stdio.h>

4 int main()

5 {

6 int i=0;

7 while(++i < 5 )

8 {

9 printf("%d\n",i);

10 }

11 return 0;

12 }

Output:

1
2
3
4

Prepared by T.Aruna Sri, Dept of CSE Page 47


Programming With C UNIT 1

Example program for post – increment operators:

1 #include <stdio.h>

2 int main()

3 {

4 int i=0;

5 while(i++ < 5 )

6 {

7 printf("%d\n",i);

8 }

9 return 0;

10 }

Output:

1
2
3
4
5

Example program for pre - decrement operators:

1 #include <stdio.h>

2 int main()

3 {

4 int i=10;

5 while(--i > 5 )

6 {

Prepared by T.Aruna Sri, Dept of CSE Page 48


Programming With C UNIT 1

7 printf("%d\n",i);

8 }

9 return 0;

10 }

Output:

9
8
7
6

Example program for post - decrement operators:

1 #include <stdio.h>

2 int main()

3 {

4 int i=10;

5 while(i-- > 5 )

6 {

7 printf("%d\n",i);

8 }

9 return 0;

10 }

Output:

9
8
7

Prepared by T.Aruna Sri, Dept of CSE Page 49


Programming With C UNIT 1

6
5

EXPRESSIONS :

An expression is a sequence of operands and operators that reduces to a single value. Expression
can be simple or complex. An operator is a syntactical token that requires an action be taken.
An operand is an object on which an operation is performed.
A simple expression contains only one operator.E.g: 2 + 3 is a simple expression whose
value is 5.A complex expression contains more that one operator. E.g: 2 + 3 * 2.
To evaluate a complex expression we reduce it to a series of simple expressions. In this first we
will evaluate the simple expression 3 * 2 (6)and then the expression 2 + 6,giving a result of 8.
The order in which the operators in a complex expression are evaluated is determined by
a set of priorities known as precedence, the higher the precedence ,the earlier the expression
containing the operator is evaluated. If two operators with the same precedence occur in a
complex expression ,another attribute of an operator ,its associativety ,takes
control.Associativity is the parsing direction used to evaluate the expression. It can be either left-
to-right or right-to-left .When two operators with the same precedence occur in an expression
and their associativity is left-to-right ,the left operator is evaluated first. For example ,in the
expression 3*4/6 ,there are two operators multiplication and division ,with the same precedence
and left-to-right associativity .Therefore the multiplication is evaluated before the division .

The following table shows the precedence and associativity of operators:

Prepared by T.Aruna Sri, Dept of CSE Page 50


Programming With C UNIT 1

ARITHMETIC EXPRESSIONS :
It is a combination of variables, constants and operators arranged according to the syntax of C
language.
Some examples - A * B – C ,(M + N) * (X + Y)
Evaluation of expressions : Expressions are evaluated using an assignment statement of the form
Variable = expression
Eg x = x*y + z-3 *(z *y)

Precedence of arithmetic expressions is used to evaluate a expression to provide un ambiguous


way of solving an expression. The highest precedence operator is evaluated then next highest
precedence operator until no operator is present.
The precedence or priorities are as follows
High * / %
Low + -
An expression is evaluated in left to right and value is assigned to variable in left side of
assignment operator.
/* program to demonstrate evaluation of expressions */
#include<stdio.h>
main()
{
float a,b,c,x,y,z;
a=9;b=23;c=3;
x=a-b/3+c*2-1;
y=a-b/(3+c)*(2-1);
z=a-(b/(3+c)*2)-1;
printf("values of x,y,z are %d%d%d",x,y,z);
}

TYPE CONVERSION:
In an expression that involves two different data types ,such as multiplying an integer and a
floating point number to perform these evaluations ,one of the types must be converted.
We have two types of conversions

1.Implicit Type Conversion


2.Explicit Type Conversion

IMPLICIT TYPE CONVERSION :


When the types of the two operands in a binary expression are different automatically converts
one type to another .This is known as implicit type conversion .
•C permits mixing of constants and variables of different types in an expression.
•C automatically converts any intermediate values to the proper type so that the expression can
be evaluated without loosing any significance.
•This automatic type conversion is know as implicit type conversion
•During evaluation it adheres to very strict rules and type conversion.

Prepared by T.Aruna Sri, Dept of CSE Page 51


Programming With C UNIT 1

•If the operands are of different types the lower type is automatically converted to the higher
type before the operation proceeds. The result is of higher type.

Conversion rules
 If one operand is long double, the other will be converted to long double and result will be
long double.
 If one operand is double, the other will be converted to double and result will be double.
 If one operand is float, the other will be converted to float and result will be float.
 If one of the operand is unsigned long int, the other will be converted into unsigned long int
and result will be unsigned long int.
 If one of the operand is long int, the other will be converted to long intand the result will be
long int.
 If one operand is unsigned intthe other will be converted to unsigned intand the result will be
unsigned int.

EXPLICIT TYPE CONVERSION :


 Explicit type conversion uses the unary cast operator ,to convert data from one type to
another.
 The process of such a local conversion is known as explicit conversion or casting a value.
The general form is (type_name) expression
 To cast data from one type to another ,we specify the new type in parentheses before the
value we want converted.
For example ,to convert an integer ,a , to a float, we code the expression like (float) a

Many times there may arise a situation where we want to force a type conversion in a way that is
different from automatic conversion.
Consider for example the calculation of number of female and male students in a class
Ratio = female_students /male_students
Since if female_students and male_students are declared as integers, the decimal part will be
rounded off and its ratio will represent a wrong figure.This problem can be solved by converting
locally one of the variables to the floating point as shown below.
Ratio = (float) female_students/ male_students
The operator float converts the female_studentsto floating point for the purpose of evaluation of
the expression.Then using the rule of automatic conversion, the division is performed by floating
point mode, thus retaining the fractional part of the result.

THE CONDITIONAL EXPRESSION OPERATOR


This conditional expression operator takes THREE operators. The two symbols used to denote
this operator are the ? and the :. The first operand is placed before the ?, the second operand
between the ? and the :, and the third after the :. The general format is,

condition ? expression1 : expression2

Prepared by T.Aruna Sri, Dept of CSE Page 52


Programming With C UNIT 1

If the result of condition is TRUE ( non-zero ), expression1 is evaluated and the result of the
evaluation becomes the result of the operation. If the condition is FALSE (zero), then
expression2 is evaluated and its result becomes the result of the operation. An example will help,
s = ( x < 0 ) ? -1 : x * x;

If x is less than zero then s = -1


If x is greater than zero then s = x * x
Example program illustrating conditional expression operator
#include <stdio.h>
main()
{
int input;
printf("I will tell you if the number is positive, negative or zero!"\n");
printf("please enter your number now--->");
scanf("%d", &input );
(input < 0) ? printf("negative\n") : ((input > 0) ? printf("positive\n") :
printf("zero\n"));
}

Sample Program Output


I will tell you if the number is positive, negative or zero!
please enter your number now---> 32
positive

Input Output Statements


Introduction
In c language input and output functions are accomplished through library function. The header
file for I/O function is <stdio.h>. In C there are two types of I/O functions. They are console I/O
and file I/O. Console I/ o function takes I/P from keyboard and produces o/p on the screen. The
console Input / Output functions are also called as Standard input / output functions.
Classification:
The console I / O function are classified as shown below.

Prepared by T.Aruna Sri, Dept of CSE Page 53


Programming With C UNIT 1

Formatted I / O Functions
Formatted I / O means reading and writing data in formats which are desired by the user. The
function used to input action is scanf() and output action is printf().

The printf() Function


Printf() is used to print or display data on the console in a formatted form.
The format of printf() is printf( “control string”, list of arguments);
Control string contains the formatting instructions within quotes. This can contain
(i) characters that are simply printed as they are
(ii) Conversion specifications with begins with format specifier (%) sign.
(iii) Escape sequences.
Arguments values get substituted in the place of appropriate format specifications. Arguments
can be variables, constants, arrays or complex expressions. The percentage (%) followed by
conversion character is called format specifier. This indicates the type of the corresponding data
item.

Format specifiers

Application of printf() Function


The printf() function is used to print the different types of output. This is given below.
(i) Printing given data
(ii) The printf() statement cab be used without format specifier, just to print the given data. This
is as shown below.
printf( “ C prigramming is easy’ );
Output:
C programming is easy
(iii) Printing numbers
To print integers % d or % I is used to print floating point % f is used.
This is as shown below.
int a = 5
float d = 10.3;
printf( “the value of integer a is %d’, a );
printf( “the value of float d is %f’, d );
Output:

Prepared by T.Aruna Sri, Dept of CSE Page 54


Programming With C UNIT 1

The value of integer a is5


The value of float is 10.3
In the above instance instead of using two printf() statements only one printf() can be used. This
is as shown below
printf( “the value of integer a is %d \n, the value of float d is %f” a,d);
Output
The value of integer a is 5
The value of float is 10.3
(iv) Printing character / string data
To print character % c used and to print a string % s format specifier is used. This is shown
below.
print c( “this is % c %s”, ‘a’, “book”);
The characters are always given in single quote and strings are enclosed in quote (double).

Escape Sequence in printf() Function


In addition to format specification, escape sequence can also be used in printf(). These are
specified in the control string portion of the printf() and are used mainly for screen formatting.
All escape sequence are provided with slash ( / ). Since back slash is considered as an “escape”
character. These sequences are called escape sequences.
These sequences cause an escape from the normal interpretation of a string. So that the next
character (after blank slash) is recognized as having a special meaning.

(i) printf(“Teacher asked, \” did you understand ?\” ”);


This will print
Teacher asked, “did you understand?”
(ii) printf(“The sequence is a<b, where \’b\’ is > 0”);
This will print
The sequence is a<b, where ‘b’ is >0
(iii) printf(“Hi,\n How are \n You?”);

Prepared by T.Aruna Sri, Dept of CSE Page 55


Programming With C UNIT 1

This will print


Hi
How are
You

Minimum Field Width Specifier (MFWS)


 An integer placed between the % sign and format code is called minimum field width
specifier or % number format code; ex. %5d.
 If string or number to be printed is longer than that minimum it will printed as such.
 Minimum field width specifiers are used to make the O/P such that it reaches the minimum
length specified. This is done by padding.
 Default padding is done with spaces.This is used most commonly produce table in which
column line up.If we wish to pad the space (if any) with zeros, place zero before MFWS.

For example %d, will pad a number with ‘zeros’ if numbers is less than five digits. So that
the total length is 5. %d will pad a number with ‘apace’. If number is less than five digits. So
that the total length is five.
The following example demonstrates the working of minimum field width specifier.
Double count;
Count = 10.51324; // here total digits are 8, includes dot ( . )
operators.
printf (“ %f” , count);
printf (“ %10f” , count);
printf (“ %010f” , count);
Output
10.51324
10.51324 // inserts 2 blank spaces. So that total length = 10
digits
0010.51324 // inserts 2 zeros. So that total length = 10 digits

The Precision Specifier


Precision specifier follows minimum field width specifier (if given).
 It consists of a period followed by an integer (i.e. for ex %5.1d). the way it works depends
upon data types used.
 When precision is applied to float data, it determines the number of decimal places displayed.
For example % 8.5f displays a number at least 8 character width with four decimal places.
 When precision is applied to string, the precision specifier species maximum field length. For
example %5.9S, displays a string at least five and not exceeding of characters long.
 If string is longer than the maximum field width the end character are truncated, so that string
length is equal to integer types.
 The precision specifier determines the minimum number of digits. That appears for the given
number. Leading zeros are added to achieve the required number of digits. This is shown in
printf(“5.4f\n”, 176.012543871);
printf(“2.8d\n”, 5214);
printf(“8.12S\n”, “This is C language book”);
Output

Prepared by T.Aruna Sri, Dept of CSE Page 56


Programming With C UNIT 1

176.012543871
00005214
This is C language book

The scanf() Function


The scanf() reads the input data from standard input device. i.e.keyboard.
The general format of the scanf() function is
scanf( “format string” list of arguments );
where format string consists of format specifiers and arguments consists of address of variables.
To this corresponding address the data read from keyboard is sent. The address of the variable is
denoted by ampersand symbol ‘&’ (it is called as ‘’address of the operator Note that the values
that are supplied through keyboard must be separated by either blank tabs or newlines. Escape
sequences are not included in scanf() function.
(i) To read integer data:
int i ;
---
scanf(“%d”, &i);
(ii) To read floating point data:
floatf;
---
scanf(“%f”, &f);
(iii) To read character data;
char sam, john;
---
scanf(“%c”, &sam, &john);
(vii) To read more than one data types at a time
int i;
float b;
char c;
string s;
---
scanf(“%d %f %c %s”, &i, &b, &c, &s );

Unformatted I / O Function
A simple reading of data from keyboard and writing to I / O device,without any format is called
unformatted I / O functions. This is classified as string I / O and character I /O.

Character Input/Output(I/O)
In order to read and output a single character character I / O functions
are used. The functions under character I / O are
(I) getchar()
(II) putchar()
(III) getch()
(IV) getche()

Prepared by T.Aruna Sri, Dept of CSE Page 57


Programming With C UNIT 1

The getchar( ) function


Single characters can be entered into the computer using the C library function getchar. The
getchar function is a part of the standard C I/O library. It returns a single character from a
standard input device typically a keyboard. The function does not require any arguments, though
a pair of empty parentheses must follow the word getchar.
The general syntax
Character variable=getchar();
Where character variable refers to some previously declared character variable.Example:
A C program contains the following statements
char c;
…………….
C=getchar();
The first statement declares that c is a character-type variable. The second statement causes a
single character to be entered from the standard input device and then assigned to c. If an end-of-
file condition is encountered when reading a character with getchar function, the value of the
symbolic constant EOF will automatically be returned. (This value will be assigned within the
stdio.h file. Typically, EOF will be assigned the value -1, though this may vary from one
compiler to another).
The getchar function can also be used to read multi character strings, by reading one character at
a time within a multi pass loop.
int i, j;
char a, b;
i = 65;
b = ‘d’
j = getchar(); // I / O int data type into j
a = getchar(); // I / O char data type into a
putchar(i);
putchar(b);
putchar(a);
putchar(j);
Output
a
d

--- (according to user I / O)


Drawback with getchar() is that buffers the input until ‘ENTER’ key is pressed. This means that
getchar does not see the characters until the user presses return.This is called line buffered input.
This line buffering many leave one or more characters waiting in the input queue, which leads to
‘errors’ in interactive environment. Hence alternatives to getchar() is used.

.The putchar( ) function:


Single characters can be displayed using the C library function putchar.
This function is complementary to the character input function getchar.
The putchar function, like getchar, is a part of the standard C I/O library.It transmits a single
character to a standard output device. The character being transmitted will normally be presented

Prepared by T.Aruna Sri, Dept of CSE Page 58


Programming With C UNIT 1

as a character type variable. It must be expressed as an argument to the function, enclosed in


parentheses, following the word putchar.
The general syntax is
putchar(character variable)
where character variable refers to some previously declared character variable.
A C program contains the following statements
Char c;
………
putchar(c);
If putchar() is called with integer value, the equivalent ASCII character is displayed.

Alternatives to getchar()
The two common alternative functions to getchar() are
getch()
getche()
The getch() function reads a single character at a time and it waits for key press. It does not echo
the character on the screen. The getche() is
same as getch()/ but the key is echoed. This is illustrated below.
char ch;
Ch = getch() // let key press = k
putchar(ch);
Output

String I / O
In order to read and write string of characters the functions gets() and puts() are used gets()
function reads the string and puts() function takes the string as argument and writes on the
screen. This is illustrated below char name [50]
puts (“Enter your name”);
gets (name);
puts(“ The name entered is “)
Output:
Enter your name: Fredric /* string as entered by user*/
The name entered is: Fredric
Note: Char name (50) is character array declaration.

STATEMENTS AND BLOCKS :

A statement causes an action to be performed by the program. It translates directly in to one or


more executable computer instructions.

A statement causes an action to be performed by the program. It translates directly into one or
more executable computer instructions. You may have noticed that we have used a

Prepared by T.Aruna Sri, Dept of CSE Page 59


Programming With C UNIT 1

semicolon at the end of the statements in our programs. Most statements need a semicolon at
the end; some do not

STATEMENT TYPES:

1.NULL STATEMENT : The null statement is just a semicolon (the terminator).


Eg: //null statement
Although they do not arise often, there are syntactical situations where we must have a statement
but no action is required .In these situations we use the null statement.

2.EXPRESSION STATEMENT :
An expression is turned in to a statement by placing a semicolon(;)after it.
expression; //expression statement
Eg: a=2;

3.RETURN STATEMENT :
A return statement terminates a function. All functions ,including main, must have a return
statement. Where there is no return statement at the end of the function ,the system inserts one
with a void return value.
return expression; //return statement
The return statement can return a value to the calling function. In case of main ,it returns a value
to the operating system rather than to another function. A return value of zero tells the operating
system that the program executed successfully.

4.COMPOUND STATEMENTS:
A compound statement is a unit of code consisting of zero or more statements .It is also known
as a block. The compound statement allows a group of statements to become one single entity.

Prepared by T.Aruna Sri, Dept of CSE Page 60


Programming With C UNIT 1

A compound statement consists of an opening brace ,an optional declaration and


definition section ,and an optional statement section ,followed by a closing brace.
Eg: {
//Local Declarations
int x;
int y;
int z;
//Statements
x=1;
y=2;

} //End Block

Prepared by T.Aruna Sri, Dept of CSE Page 61

You might also like