01 - Introduction To Computer and Algorithm
01 - Introduction To Computer and Algorithm
INTRODUCTION TO COMPUTER
PROGRAMMING
• Main Objective:
– Students can independently write, read, compile, debug and execute
computer programs to solve problems, especially engineering related
problems.
COURSE OUTCOME
CO1 Ability to define and describe programming concepts and
principles (PO1)
LAB MODULE
No Title / Topic
1 Introduction to Linux Environment, Editor and Compiler
2 Problem Solving Techniques, Algorithm: Pseudo code and Flowchart
3 Introduction to C Programming
4 Selection Structures
5 Repetition Structures (Loop)
6 Functions 1
7 Functions 2
8 Arrays 1
9 Arrays 2
ASSESSMENT
4 main components:
Theoretical Test 20%
Lab Assignments 20% (4 Lab Assignments, 1 written
assignment)
Lab Test 10%
Final Exam 50%
Assignments are assessed individually (in lab assignment)
Theoretical test are written test.
Attendances are compulsory! – use QR code
REFERENCES
LECTURE OUTLINE
1. INTRODUCTION TO COMPUTER
2. INTRODUCTION TO COMPUTER PROGRAMMING
3. INTRODUCTION TO C PROGRAMMING LANGUAGE
A Brief Look At Computer
Computer
is a device that receives input, stores and processes data, and provides output
in a useful format.
Computers process data according to sets of instructions called computer
programs
Example: laptops, PCs, mainframes, mobile phones, washing-machines, TV
sets, cars contain computers
Hardware
Physical components of a computer
Example: Keyboard, screen, mouse, disks, memory, CD-ROM, and processing
units
Software
Programs that run on a computer
Example: Operating System such as windows XP -Vista -7-10-11,
Word processing packages such as MS Word, registration
program
Computer
Hardware/Components
Software
How Computer Processes Information?
Computers are NOT intelligent
Computers do what we tell them to do they don’t do anything by
themselves.
We must clearly tell a computer what to do in a step by step manner using
a programming language.
The scenario:
“At the end of each month, a clerk enters the employee name, number of days present and
absent, and the number of overtime done in the system. The system then calculates the normal
salary, the amount for overtime and the total salary. The clerk then saves the information in the
computer hard disk, and takes a backup on a cd. A report is produced for the clerk to be shown
to the manager. “
Task: Identify the following for that particular system
1. Input
2. Process(es)
3. Output
4. Storage
Exercise: Distinguishing between input-process and
output-storage
The scenario:
“At the end of each month, a clerk enters the employee name, number of days present and absent, and the
number of overtime done in the system. The system then calculates the normal salary, the amount for overtime
and the total salary. The clerk then saves the information in the computer hard disk, and takes a backup on a cd.
A report is produced for the clerk to be shown to the manager. “
1. Input: the employee name, number of days present and absent, the number of
overtime
2. Process(es): calculate normal income, calculate amount for overtime, calculate total
salary
3. Output: Report
4. Storage: Harddisk, CD-ROM
Example of Past Year Question
Identify the Input, Storage and Output of the following given statement:
At the end of each semester, a lecturer enters the students’ marks for
assignment, test, and examination in a system. The system then calculates the
final marks and determines the grade received by the student. As a result, a
report is generated. The lecturer saves the report in the computer hard disk,
and takes a backup on a drive.
INTRODUCTION TO
COMPUTER PROGRAMMING
Programming / Program / Programmer
To
solve problem using algorithms, we
have to:
READ and understand the problem
If THINK about different solutions to
needed the problem
DESIGN an approach that will
solve the problem
IMPLEMENT that design
TEST to see if it works
31
1. Pseudo code
2. Flowchart
32
Input Data
Output Result
End
38
BASIC SYMBOLS IN FLOW CHART
TERMINAL: Start/End of a program
INPUT/OUTPUT: – where the user of the program is
asked for information (INPUT) or where the
program displays a result (OUTPUT)
PROCESSING: shows any mathematical operation
(e.g. addition, substraction, etc)
Flow direction
39
Example 1
Write an algorithm that display a message to the
screen as “Hello World!”.
End
40
Example 2:
Write a flowchart that calculates and prints the
SUM of two integers A and B.
Pseudo Code Flow Chart
Begin
• Begin
• Input A and B Input A, B
• Calculate A + B
• Print result of SUM
Calculate A + B
• End
Print SUM
End
1) Write an algorithm (pseudo code and flow chart) to
read input of 3 test marks, calculate the average and
display the final marks.
• Begin
• Input test1, test2 and test3
• Calculate average
• Print result of average
• End
Pseudo Code Flow Chart
• Begin
• Input test1, test2 and test3
• Calculate average
• If average >=60
• Display average &
“Passed”
• Otherwise
• Display average &
“Failed”
• End
END