Programing I
Programing I
Minicomputer
Mainframe
Supercomputer
Computer Classification
Price
Processing Speed
Storage Capacity
Powerful
Single-user or Multi-user
Computer Size
Companies size
Computer Classification
A single-user computer that can perform all input, processing, output and storage operations on
its own.
Two types of personal computer are desktop computer and workstation.
Mobile computer and mobile device.
notebook computer
Portable, small enough to fit on your lap.
Also called a laptop computer.
Usually more expensive than a desktop
computer with equal capabilities.
Mobile computer and mobile device.
Tablet PC
Mid-Range Server
More powerful and larger that a workstation and can support up to 4,000
users at one time.
Formerly known as minicomputer.
Mainframe Computer
Computer hardware - Are physical parts/ intangible parts of a computer. eg Input devices, output devices,
central processing unit and storage devices
Computer software - also known as programs or applications. They are classified into two classes namely -
system software and application software
Hardware Software
Secondary
RAM I/O Devices
Storage
COMPUTER HARDWARE
There are five main hardware components in a computer system: Input,
Processing, Storage, Output and Communication devices.
Input Device
Input device is any peripheral piece of computer
Main Examples
Hard Disk
Optical Disk
Flash memory
Output Device
An output device is any piece of computer
a computer
1. .
2.
3.
Known as Operating System is used to control all hardware
components of computer and serves as an interface between
user and hardware.
1. Control all Components of Computer
2. Allows us to communicate with the computer
For example of OS:
Microsoft Windows
Linux
Unix
Mac OSX
DOS
Application software is used or design for the specific purpose of the user.
For example:
MS-WORD
MS-EXCEL
MS-POWER POINT
MS-ACCESS
Game
Paint
A program is a sequence of instructions that instructs the
computer what to do.
What is programming?
Programming is the ability to get computer to perform useful
tasks for us
Programming is about problem solving
Programming is about solution development
From the problem to an algorithm
From algorithm to a program
Programming is about how computer works
Programming Languages
Types of Programming Languages
Machine language
Assembly language
High level languages
High Level Programming Languages:
Imperative (Procedural) Languages e.g. C , C++ , Java
Resemble human languages
Are designed to be easy to read and write
Must be translated to zeros and ones for the CPU
to execute a program
Compilers
Translate high-level language to
machine language
Source code
the original program in a high level language
Object code
the translated version in machine language
Slide 35
Problem Solving
Whatever activity a human being or machine do for achieving a specified
objective comes under problem solving.
Example1: If you are watching a news channel on your TV and you want
to change it to a sports channel, you need to do something i.e. move to
that channel by pressing that channel number on your remote. This is a
kind of problem solving.
3. Work the problem by hand (or with a calculator) for a simple set of
data.
To describe the process of solving a problem with sequential logic, we use the top-down
others
You must break the main tasks that must be accomplished into
smaller ones in order to be able to write fully developed code.
Problem1: Write an algorithm to read two numbers and find their sum.
Inputs to the algorithm: First num1. Second num2. Expected output: Sum
of the two numbers.
Algorithm:
Step1: Start
Step6: End
Example of Pseudocode….
Problem 2: Find the area of a Circle of radius r.
Inputs to the algorithm: Radius r of the Circle
Expected output: Area of the Circle
Algorithm:
Step1: Read\input the Radius r of the Circle
Step2: Area= π r 2
Step3: Print Area
Step4:END
Example of pseudocode
Example
Write a algorithm to find out number is odd or even?
step 1 : start
step 2 : input number
step 3 : rem=number mod 2
step 4 : if rem=0 then
print "number even“
else print "number odd"
end if
step 5 : stop
Flowchart
1. Sequence
2.Selection
3. Loop (Repetition)
Sequence
Begin
input hours
input rate pay = hours * rate
print pay
End
Selection
1.Start
2. Read/input A and B
3. If A greater than B then C=A
4. if B greater than A then C=B
5. Print C
6. End
Selection
1. Start
2. Read/input x
5. Print F
6. End
Selection
Problem3: A algorithm to find the largest value of any
three numbers.
1.Start
6. Print Max
7. End
Loop (repetition structure)
The loop allows a statement or a sequence of
statements to be repeatedly executed based
on some loop condition.
1.Start
2. I ← 0
4. I ← I+2
6. End
Loop (repetition structure)
loop
what is the output for
the following flow chart?
A) 2, 10
B) 2, 8
C) no output
C++ Program
66
C++ Program Structure
Comments
Libraries
main function
void main()
...... Lib M {
Links to Libraries cout<<“We come to C++
Main Program programming“;
{ }
input & initialisation Expressions, Statements function calls
output & termination
}
Simple Program
#include <iostream> It tells the compiler, during the
preprocessing stage, to find a file, named
iostream, and insert it verbatim into the
using namespace std; source file being compiled.
All symbols in that namespace (functions)
will become visible without adding the
namespace prefix. Otherwise, you have to
void main() add std as a prefix. Ex: std :: cout << “My
{ first C++ program”;
Identifiers are the names of variables, functions, labels, and various other user-defined objects.
Rules of a valid identifier:
Keywords are the commands that make up the C++ language. These keywords cannot be used for
identifiers.
Constants and Variables
In order to use input and output statements in our programs, we must include the library:
#include <iostream.h>
cout STATEMENT
is used to print values and explanatory text to the screen.
cout << “age = ” << age << “ years” << endl;
if the value of age is 20, the output of the statement is age = 20 years
Cont..
cin STATEMENT
is used to enter values from the keyboard when a program is executed.
cin >> age;