Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
91 views

01 - Introduction To Computer and Algorithm

Here are the inputs, processes, outputs and storage for the given scenario: 1. Input: - Employee name - Number of days present - Number of days absent - Number of overtime hours 2. Processes: - Calculating normal salary - Calculating overtime amount - Calculating total salary 3. Output: - Report showing employee details and salaries for the manager 4. Storage: - Information saved in the computer hard disk - Backup of information taken on a CD So in summary, the inputs are the data entered by the clerk, the processes are the calculations done by the system, the output is the report generated, and the storage is where the information
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

01 - Introduction To Computer and Algorithm

Here are the inputs, processes, outputs and storage for the given scenario: 1. Input: - Employee name - Number of days present - Number of days absent - Number of overtime hours 2. Processes: - Calculating normal salary - Calculating overtime amount - Calculating total salary 3. Output: - Report showing employee details and salaries for the manager 4. Storage: - Information saved in the computer hard disk - Backup of information taken on a CD So in summary, the inputs are the data entered by the clerk, the processes are the calculations done by the system, the output is the report generated, and the storage is where the information
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

KMJ16803

INTRODUCTION TO COMPUTER
PROGRAMMING

Introduction to Computer and


Computer Programming

Mrs Siti Kamariah Md Sa’at


FTKK, UniMAP
COURSE INFORMATION
• Contributes 3 units:
– 2 hours lectures (28 hours) Sync/Async
– 2 hours labs (28 hours)

• 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)

CO2 Ability to apply GNU/Linux for coding, compiling, executing and


debugging computer programs using IDE platform (PO5)

CO3 Ability to evaluate and formulate solution for engineering related


problems using computer programming techniques (PO2)

CO4 Ability design and create computer programs to solve engineering


related problem (PO3)
PO-Domain
PO PO KEYWORD
PO1 Engineering Knowledge
PO2 Problem Analysis
PO3 Design/Development of Solution
PO4 Investigation
PO5 Modern Tool Usage
PO6 The Engineers and Society
PO7 Environment and Sustainability
PO8 Ethics
PO9 Individual and Teamwork
PO10 Communication
PO11 Project Management and Finance
PO12 Lifelong Learning
TECHING PLAN
 LECTURE 2 HOURS/WEEK – 14 WEEK
Taxonomy Delivery Assessment
Week Topic Lecturer
Domain Activities Activities
1-2 Introduction Mrs Siti
Computer System and Linux environment. Problem solving Kamariah Md
Lecture
techniques (Pseudo-code & flow chart) and C Languages (C C3 Sa’at
program structure & operators, logic comparison, input & output
statements).
3-4 Program Control Structures: Selection Lab Assignment
Lecture
Sequential structure, selection structure (if, if-else, switch), nested C3 1
selection structure
5 Program Control Structures: Repetition
Lecture
Repetition structure (for, while, do-while), nested selection C5 Assignment
structure
6 MID TERM BREAK
7-8 Program Control Structures: Repetition (cont) Lab Assignment
Repetition structure (for, while, do-while), nested selection Lecture 2
structure C5 Test 1
Part 2
Taxonomy Delivery Assessment
Week Topic Lecturer
Domain Activities Activities
9-10 Function (Part I) Dr
Function definition, function call, function prototype, value- Muhammad
C5 Lecture
returned function and parameters passing in function (by value). Firdaus Abdul
Muttalib
11 Function (Part 2)
Lab Assignment
Parameters passing in function (by reference) and recursive C6 Lecture
3
function.
12 Arrays (Part I) Lecture
C6
Declaration, operations on array and 2-dimensional arrays.
13-14 Arrays (Part 2)
C6 Lecture
Array and function (as passing parameter in a function)
14 Arrays (String) Lab Assignment
Strings declaration, operations and pre-defined function for Lecture 4
string. C6 Test 2
15 Pointers C5 Lecture
Lab Test
Pointers declaration, operations and manipulation P3
16 Study week
17 Exam week Final Exam
18 Exam week
19 Exam week
LAB

 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

 Hanly, J.R. and Koffman, E.B., “Problem Solving and


Program Design in C, Global Edition”, 8th Ed., Pearson,
2016.
 Deitel & Deitel, “C How to Program”, Global Edition”,
8th Ed, P,earson , 2016.
 Etter,, M.D, “Engineering Problem Solving with C ”,
Global Edition”, 4th Ed, P,earson , 2012.
NOTES 10

 Thiscourse is NOT about the language, it is


about analytical skills and to apply
programming to solve problems.
 Write C program in Linux environment/GNU
compiler applications (CodeBlocks IDE)
 Do early reading
 Do not hesitate to ask during lecture sessions
11

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.

 Computers only understand “electronic”


 High voltage/low voltage – The machine language
 Machine language is binary (two values: high/low) 1’s and 0’s
Why We Use Computer?

• Computers produce fast, accurate and reliable results.


• While computers do the boring, repetitive, ordinary tasks, we can
spend our efforts and time to work on more interesting and
creative tasks.
• The use of computers in business and manufacturing decreases
the cost of goods and services produced.
• It is more difficult and needs more time to find or grow up a skill-
full labour in IT industry, while buying an additional computer
and installing the required software on is easier and cheaper.
Input- Process-Storage-Output
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. “
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. “

Task: Identify the following for that particular system

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

• Programming in general term is planning or implementation of a task or


event command. In the computing field, is instructing a computer to
perform specific tasks.
• Computer programming can be defined as the process of planning a set of
sequence commands to be executed by a computer.
• Program be defined as a set of sequence commands that have been
determined to be executed by a computer.
• Computers are just electronic devices that have the power to perform
difficult tasks but they do not ‘KNOW’ what to do therefore - programmers
tell the computers what to do by writing programs
Types of Programming Languages
 Machine language
 Lowest-level programming language consist of
strings of numbers giving machine specific
instructions
 Example: +1300042774, +1400593419,
+1200274027
 Assembly language
 English-like abbreviations representing
elementary computer operations (translated via
assemblers)
 Example: LOAD BASEPAY, ADD OVERPAY
 High level language
 Codes similar to everyday English. Use
mathematical notations (translated via
compilers)
 Example Code:
grossPay = basePay + overTimePay
 Example high level languages: C, C++, Java
Programming Problem

Problem that can be solve using programming language.


• Suppose you want to add 34 and 56, this is easy. But to add 100 numbers is
difficult for us need to use calculator or paper and pencil. Or we can write
a program for computer to help us.

Can these problems solve by computer programming?


• Converting units from kilograms to grams.
• Counting the number of cars on a highway.
• Finding a life partner
• Total rain in a week
• How long we live
• What we want to eat for dinner
Problem Solving using Programming
Steps of Programming
1. Requirement Specification: Eliminate ambiguities, Clearly
understand the problem
2. Analyse the problem: Understand the inputs, outputs and processes
used for manipulating the data, formulas and constraints
3. Design: Write the algorithm (flowchart or pseudocode) to represent
the solution
4. Implement the algorithm: Write a program / coding
5. Testing and Debugging : Check the program
6. Documentation
Properties of Well Designed Programs

Well designed programs must :

Correct and Easy to Easy to


accurate understand maintain
and update

Efficient Reliable Flexible


INTRODUCTION TO
C PROGRAMMING LANGUAGE
29

 Computer programs are a detailed set of instructions


given to the computer
 Programs are constructed based on an ALGORITHM
which is an outline of how your computer program will
work
 ALGORITHM are a problem solving procedure or
instructions that consist of:
1. What actions you want the computer to perform
2. The order of those actions should happen in
30

 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

 The constructs used to build algorithms can be


described in two different ways:

1. Pseudo code
2. Flowchart
32

When the algorithm is written out as a well-thought series


of steps, it is called PSEUDO CODE
Itis written in easy to understand language (i.e.
ENGLISH)
Itis written very similar to the way that you would
code it into your 3rd Generation Language (i.e. C
Language)
33

 Create a detailed set of instructions


(pseudo-code) that will tell us:
 How to eat a banana

 Make your instructions as detailed as


possible, so that even someone who
has never eaten a banana before
can understand them
34

1. Using your hand, get a yellow crescent-shaped fruit called a “banana”

2. Peel the outer skin off the banana

3. Eat the banana


i. Put a small section of banana in your mouth
ii. Bite down on the banana
iii. Chew the banana by opening and closing your mouth
iv. Once the banana has been chewed, swallow the banana
v. Repeat until banana is finished

4. Throw out the used banana peel


35

WAKE UP AMIN 1 WAKE UP AMIN 2


1. Get out of bed 1. Get out of bed
2. Take off pyjamas 2. Take off pyjamas
3. Take a shower 3. Get dressed The order of
4. Get dressed 4. Take a shower actions are very
important!
5. Eat breakfast 5. Eat breakfast
6. Drive to school 6. Drive to school
RESULT RESULT
• Amin arrives in a great • Amin arrives in not too
mood ready to work  great a mood since she’s
soaking wet 
36

 The algorithm can also be written as a FLOW CHART


 The flow chart is a visual- form of an algorithm
 Performs as graphic organiser (a picture that helps
organize your thoughts)
 It uses a collection of basic symbols that are used to
organize your algorithm
 These symbols are connected by arrows that show how
the algorithm “flows”
37
 Example: Begin

Input Data

Process 1 Decision Process 2

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)

DECISION: represents any action where the


computer is making a decision

Flow direction
39

Example 1
 Write an algorithm that display a message to the
screen as “Hello World!”.

Pseudo Code Flow Chart


Begin
• Begin
• Print Message Print “Hello World!”
• End

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.

2) Additional to (1), if the final marks is 60 and above,


display mark and “Passed”, otherwise display mark
and “Failed”.
42

Pseudo Code Flow Chart

• 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

You might also like