C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
2. Outline
What is a Computer?
Computer Characteristics
Memory
Operating System
Desirable Programming Characteristics
3. Introduction to Computers
Today’s computers come in many forms
Supercomputer and Mainframe
Minicomputer
Workstation
Personal computer
4. Introduction to Computers (cont..)
Mainframe and large minicomputers are used by many
business, universities, hospitals and government
agencies to carry out sophisticated scientific and
business calculations.
Mainframe Computers are expensive
5. Introduction to Computers (cont..)
Personal Computers are small and inexpensive.
Personal Computers are used extremely in most of
the schools and businesses.
EvenYou are using Personal Computer to learn C
language !!!
6. What is a Computer?
A digital computer is an electronic programmable
machine that can process almost all kinds of data
The programmable feature has made the computer
unique as compared to other machines.
7. What is Program?
A program is a set of instructions, written in a
particular sequence in a computer-related language
8. Block Diagram of Computer
A Computer has four main components
1. Input Device
2. Memory
3. Central Processing Unit (CPU)
4. Output device
10. Block Diagram of Computer (cont..)
Input device:
The input devices are used to input data to computer.
Example: Keyboard, Mouse etc.
It converts the input information to the form which is
usable by the computer.
Whenever input is supplied by the input device(s), first goes
to the memory.
11. Block Diagram of Computer (cont..)
Central Processing Unit (CPU):
The CPU acts as the computer brain
CPU is responsible for the overall working of all
components of the computer.
12. Block Diagram of Computer (cont..)
CPU consists of two parts:
1. Arithmetic Logic Unit (ALU)
2. Control Unit (CU)
1. The ALU performs arithmetic operations and conducts the
comparison of information for the logical decisions.
2. The Control Unit is responsible for sending/receiving the
control signals from/to all components.
13. Block Diagram of Computer (cont..)
Memory:
The memory of computer is of two types:
Primary memory
Secondary memory
Primary Memory:
Primary memory is faster in speed, less in size.
It consists of Read Only Memory (ROM) and Random
Access Memory (RAM)
14. Block Diagram of Computer (cont..)
Primary Memory:
Primary memory is faster in speed, less in size.
It consists of Read Only Memory (ROM) and Random Access
Memory (RAM).
ROM is a very small amount of memory used to make the computer
ready to work. (This process is called booting)
RAM contains all types of intermediate and temporary data to be used
by the CPU. In fact, CPU can work/process only that data which is
present in the RAM.
Any data present in the secondary storage (hard disk, floppy, CD etc.)
need to be first brought to the RAM to execute a work on CPU.
15. Block Diagram of Computer (cont..)
Secondary Memory:
Secondary memory is usually a very large amount of
memory which is comparatively cheaper and slower than
primary memory.
It is Permanent in nature.Thus anything stored in secondary
memory remains available even if the computer is switched off.
16. Computer Characteristics
A stored program can be executed at any time.This causes
the following things to happen-
1. A set of information, called the input data, will be entered into the
computer (from the keyboard, mouse etc. ) and stored in a portion
of the computer’s memory.
2. The input data will be processed to produce certain desired
results, known as the output data.
3. The output data, and perhaps some of the input data, will be
printed onto a sheet of paper or displayed on a monitor.
17. Computer Characteristics
Example:
A computer has been programmed to calculate the are of a
circle using the formula given a numeric value for the radius r
as the input data.The following steps are required-
1. Read the numeric value for the radius of the circle.
2. Calculate the value of the area using the above formula. This
value will be stored, along with the input data, in the
computer’s memory.
3. Print (display) the values of the radius and the correspondant
area.
4. Stop
18. Memory
Every piece of information stored within the memory is
encoded as some unique combination of zeros and ones.
Zeros and ones are called bits (binary digits)
Each bit is represented by an electronic device that is
either off (zero) or on (one).
19. Memory (cont..)
Example 1:
The primary memory of a personal computer has a capacity of 2GB.
Thus the characters/instructions can be stored in computer memory = 2
X 1024 X 1024 X 1024
= 2,14,74,83,648 bits
Example 2:
The primary memory of a personal computer has a capacity of 3MB.
Thus the characters/instructions can be stored in computer memory = 3
X 1024 X 1024
= 31,45,728 bits
20. Hardware vs. Software
The physical components of a computer are known as
hardware.
CPU, RAM, Hard disk, Keyboards etc.
The set of instructions is known as program and one or
more programs along with their documentation are called
software.
21. Hardware vs. Software (cont..)
Software used on computer can be classified as-
System Software: This category includes the software that
are used to define functioning of any computer irrespective of
the area/application where it is to be used.
Application Software: In order to use a computer for a
specific task, it needs to be instructed accordingly. Suck
instructions are provided by application software.
22. Operating System
Operating System (OS) is a system software that helps the
users to operate the computer efficiently.
The primary purpose of OS is to act as an interface
between the computer and the user.
There are three responsibilities of an operating system:
1. To provide an interface between the user and the computer
hardware.
2. To manage the resources of the computer
3. To provide support for storing and executing other softwares
23. Compiler and Interpreter
The compiler is a kind of system that translates the programs
written in high level language to machine language. The compiler
converts whole program into machine language.
Example: C-compiler, Java-compiler etc.
Interpreter is a similar software like compiler which is used to
convert high level language programs to machine language but its
working is different from that of the compiler. Interpreter converts
high level language program one line at a time to machine language
and then executes that converted line.Then the next line is
converted and executed and so on….
24. How to develop a program?
1. Analyze the problem to identify inputs, outputs and processing
requirements.
2. Identify various processing steps needed to solve the problem and
represent them in particular way (algorithm, pseudo code, flow chart
etc.)
3. Refine step 2 in a way that all the processing steps are detailed enough.
4. Add the syntax of the programming language to the above
representation.
5. Type the program and compile it after removing all syntax errors.
6. Run the program and check it with different types of input to verify its
correctness. If there is any mistake, correct it and continue with step 4.
25. Algorithm
Algorithm is a complete step by step representation of the solution of a
problem, represented in English like language.
Problem:Write a program to find the average of n numbers.
Algorithm:
– Read the value of n.
– Assign 0 to sum.
– Repeat n times.
– Read number.
– Add number to sum
– End repeat
– Divide sum by n to get the average.
– Print average.
26. Pseudo Code
Pseudo Code is a formal representation that represents every step in a formal
way which is very close to the actual programming language representation.
Pseudo code: (For same problem given to previous slide)
1. START
2. read n
3. sum 0
4. for i 1 to n do
5. read number (i)
6. sum sum + number (i)
7. end for
8. average sum/n
9. print average
10. STOP
27. Flow Chart
Flow chart is the graphical symbols to represent the steps.
28. Software Development Life Cycle
In order to develop any program/software, the following
five phases should be followed:
1. Requirement Analysis
2. Software Design
3. Software Coding
4. Software Testing
5. Software Installation and Maintenance
29. Desirable Programming Characteristics
1. Integrity: This refers to the accuracy of the calculations.
2. Clarity: Refers to the overall readability of the program, with
particular emphasis on its underlying logic.
3. Simplicity: The clarity and accuracy of a program are usually are
usually enhanced by keeping things as simple as possible.
4. Efficiency: It is concerned with execution speed and efficient
memory utilization.
5. Modularity: Many programs can be broken down into a series of
identifiable subtasks.
6. Generality: We may design a program to read in the values of
certain key parameters rather than placing fixed values into the
program.