It C Lecture
It C Lecture
It C Lecture
Introduction to computers
Contents
• Computer Defined
• RAM
• Set of Instructions
• Flowchart
Computer
COMPUTER
• Input
• Process
• Output
• Storage
Is this a Computer?
• Input
• Process
• Output
• Storage
Is this a Computer?
• Input
• Process
• Output
• Storage
Is this a Computer?
• Input
• Process
• Output
• Storage
Charles Babbage
(Father of computer)
Input
Process
Output Storage
www.comiak.com
Basic Task of a Computer
Data Information
www.comiak.com
Data / Information Processing Cycle
Set of instructions
Instruction 1 Microprocessor
Instruction 2 Central Processing Unit
Instruction n (CPU)
Keyboard
Mouse Monitor
Microphone Data Information LCD
Scanner
Input Process Output
Speaker
Webcam Printer
etc …
Information
Hard disk Drive (HDD)
CD , DVD, USB
Storage
Data / Information Processing Cycle
Input:
• Entering data in to the
computer.
• It is performed by input devices.
Data / Information Processing Cycle
Process:
• Performing operations on the data in order to convert it in to
information.
• It is performed by processing devices.
Data / Information Processing Cycle
Output:
• Presenting the
results/information.
• It is performed by output devices.
Data / Information Processing Cycle
Storage:
• Saving data, programs, output or information for future
use.
• It is performed by storage devices.
Data / Information Processing Cycle
Set of Instructions:
• Collection of instructions (Program) that converts the data in to
information.
• Contains procedure that converts data in to information.
• Stored in memory.
RAM
• Random access memory, or RAM for short , is active during the processing function.
RAM is often referred to as “temporary memory.” RAM consists of electronic circuits on
the motherboard that temporarily hold programs and data while the computer is on.
Each circuit has an address that is used by the microprocessor to transmit and store
data. When the computer is off, RAM is empty.
• RAM is constantly changing as long as the computer is on. For example, if you are writing
a paper, the word processing program that you’re using is temporarily copied into RAM
so the microprocessor can quickly access the instructions that you’ll need as you type
and format your paper. The characters you type are also stored in RAM, along with the
many fonts, special characters, graphics, and other objects that you might use to
enhance the paper. A microcomputer with 128 MB of RAM can temporarily store over
128 million characters at any one time. Many microcomputers are said to be
“expandable,” meaning that additional RAM can be added to the computer.
Application Areas of Computer
• Nowadays computers are considered backbone in many different
fields.
• 1. Education :
• Schools, Colleges, Universities
10
Application areas of computer
2. Military:
Missile launch, flight, Radar, Satellite Communications
Application areas of computer
3. Medical:
Surgery, Remote treatment, X-Ray, Ultrasound, CT
Scan
Application areas of computer
4. Research:
Simulators, Special softwares,
Surveys
Application areas of computer
5. Entertainment:
Music, Movies, Games, 3D Cinemas, Virtual Reality
Application areas of computer
6. Business:
Banks, ATM, Online Banking, Online
Shopping
Application areas of computer
7. Industry:
Production, Painting, Robots, Engine
construction
Application areas of computer
8. Transportation:
Airline, Train reservation, Air traffic control, Auto
pilot
Application areas of computer
9. Office:
Office automation, email, MS
Office
Algorithm & Pseudocode
Algorithm in Programming:
In programming, algorithm is a set of well-defined instructions in sequence to solve the problem.
Pseudocode
is an artificial and informal language that helps programmers develop algorithms. Pseudocode is
very similar to everyday English.
Pseudocode & Algorithm
• Example 1: Write an algorithm to determine a student’s final grade
and indicate whether it is passing or failing. The final grade is
calculated as the average of four marks.
Pseudocode & Algorithm
Pseudocode:
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4
• if average is below 50
Print “FAIL”
else
Print “PASS”
Pseudocode & Algorithm
• Detailed Algorithm
• Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
end
Flowchart:
Flowchart is diagrammatic /Graphical representation of sequence of steps to solve a problem. To
draw a flowchart following standard symbols are use
Statement 1
Statement 2
Statement 3
:
Flowchart – selection control structure
No Yes
Condition
else- then-
statement(s) statement(s)
Example
START
Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Input
M1,M2,M3,M4
Step 3: if (GRADE <50) then
Print “FAIL”
else
GRADE(M1+M2+M3+M4)/4 Print “PASS”
end
N IS Y
GRADE<5
0
Print Print
“PASS” “FAIL”
STOP
Example 2
• Write an algorithm and draw a flowchart to convert the length in feet
to centimeter.
Pseudocode:
• Input the length in feet (Lft)
• Calculate the length in cm (Lcm) by multiplying LFT with 30
• Print length in cm (LCM)
Example 2
Flowchart
Algorithm
• Step 1: Input Lft START
Print
Lcm
STOP
Example 3
Write an algorithm and draw a flowchart that will read the two sides
of a rectangle and calculate its area.
Pseudocode
• Input the width (W) and Length (L) of a rectangle
• Calculate the area (A) by multiplying L with W
• Print A
Example 3
Algorithm START
AL x W
W, L
• Step 2:
• Step 3: Print A
ALxW
Print
A
STOP
Flowchart – example 1
Start
Calculate
Age = current year – birth date
Display
age
End
Flowchart – example 2
Start
Read age
End
Flowchart – example 5
Begin
sum = 0
current_number = 1
NO
current_number <= 10? print sum
YES
End
sum = sum + current_number
current_number = current_number + 1
Exercises: Algorithm & Flowchart
1.) Create an algorithm and a flowchart that will
accept/read two numbers and then display the bigger
number.
2.) Create an algorithm and a flowchart that will
compute the area of a circle.
3.) Create an algorithm and a flowchart that will
compute the sum of two numbers. If the sum is below
or equal to twenty, two numbers will be entered
again. If the sum is above 20, it will display the sum.
Algorithm & Flowchart
4) Create an algorithm and a flowchart that will output
the largest number among the three numbers.
Algorithm & Flowchart
Example (1)
Write the Algorithm and Draw a flowchart to add two numbers
? Algorithm
Step-1 Start
Step-2 Input first number say A
Step-3 Input second number say B
Step-4 SUM = A + B
Step-5 Display SUM
Step-6 Stop
Or
Algorithm
Step-1 Start
Step-2 Input two numbers say A & B
Step-3 SUM = A + B
Step-4 Display SUM
Step-5 Stop
E
x
a
m
p
l
e
(
2
)
Convert
temperature from
Celsius to
Fahrenheit
C : temperature in Celsius
F : temperature Fahrenheit 4
7
Algorithm
Algorithm & Flowchart
Example (3)
Find Area and Perimeter of Square:
L : Side Length of Square
AREA
: Area of Square PERIMETER :
Perimeter of Square
Algori
thm
Step-1
Start
Step-2 Input
Area = L x L
Step-4
PERIMETER = 4 x L
Example (4)
Find Area and Perimeter of Rectangle:
L : Length of Rectangle Step-5
B : Breadth of Rectangle
AREA
Display: Area
AREA,of PERIMETER
Rectangle Step-
PERIMETER : Perimeter of Rectangle
Algorithm
6 Stop
Step-1 Start
Step-3 Area = L x B
Step-4 PERIMETER = 2 x ( L + B)
Step-6 Stop
4
8
Algorithm & Flowchart
Example (5)
Find Area and Perimeter of Circle:
R : Radius of Circle
AREA : Area of Circle
PERIMETER :
Perimeter of Circle
Algorithm
Step-1 Start
Step-2 Input Radius of Circle say R
Step-3 Area = 22.0/7.0 x R x R (or) (3.14 ×R ×R)
Step-4 PERIMETER = 2 x 22.0/7.0 x R(2 × 3.14 ×R)
Step-5 Display AREA, PERIMETER
Step-6 Stop
Example (6)
Find Area and Perimeter of Triangle:
A : First Side of Triangle
B : Second Side of Triangle
C : Third Side of Triangle
AREA : Area of Triangle
PERIMETER : Perimeter of
Triangle
Algorithm
Step-1 Start
Step-2 Input Sides of Triangle A,B,C
Step-3 S= (A + B + C)/ 2.0
Step-4 AREA = SQRT(S x (S-A) x (S-B) x(S-C))
Step-5 PERIMETER = A + B + C
Step-6 Display AREA, PERIMETER
Step-7 Stop
4
9
Algorithm & Flowchart
Example (7)
Algorithm & Flowchart to Swap Two Numbers using
Temporary Variable :
Algorithm
Step-1 Start
Step-2 Input Two Numbers Say NUM1,NUM2
Step-3 Display Before Swap Values NUM1, NUM2
Step-4 TEMP = NUM1
Step-5 NUM1 = NUM2
Step-6 NUM2 =
TEMP
Step-7 Display After Swap Values NUM1,NUM
Step-8 Stop
5
0