SlideShare a Scribd company logo
KMJ16803 INTRODUCTION TO
COMPUTER PROGRAMMING
Introduction to Computer and
Computer Programming
Prof. Dr. Abdullah bin Chik
Material Department
Faculty of Chemical Engineering & Technology
• Contributes 3 units:
– 2 hours lectures (28 hours)
– 2 hours labs (18 hours)
• Main Objective:
– Students can independently write, read, compile, debug
and execute computer programs to solve problems,
especially engineering related problems.
COURSE INFORMATION
COURSE OUTCOME
CO1 Ability to assess the basic computer programming
concepts and principles for engineering related programs.
CO2 Ability to design simple computer programs to solve
problems/issues in multidisciplinary engineering field.
CO3 Ability to use coding software editor for coding,
compiling, executing and debugging computer programs
for related engineering programs.
ASSESSMENT
• 4 main components:
– Midterm Test 1 20%
– Midterm Test 2 20%
– Assignments 20%
– Quizzes 10%
– Mini Project 30%
• Assignments are assessed individually (in lab assignment)
• Midterm tests are written test
REFERENCES
• Deitel & Deitel, “C How to Program”, Global Edition”, 8th
Ed, Pearson , 2016.
• Etter,, M.D, “Engineering Problem Solving with C ”, Global
Edition”, 4th Ed, Pearson , 2012.
NOTES
• This course is NOT about the language per se, it is
about analytical skills and to apply programming
to solve problems.
• Write C program in GNU compiler applications
(CodeBlocks IDE)
• Do early reading
• Do not hesitate to ask during lecture sessions
6
LECTURE OUTLINE
1. Introduction to Computer
2. Introduction to Computer Programming
3. Introduction to C Programming Language
7
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, and
processing units
§ Software
§ Programs that run on a computer
§ Example: Operating System such as windows 10 and 11, Word
processing packages such as MS Office 365
Computer Hardware/Components
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: Hard disk, flash drive, memory card SD etc.
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.
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
accurate
Easy to
understand
Easy to
maintain
and update
Efficient Reliable Flexible
INTRODUCTION TO
C PROGRAMMING LANGUAGE
• 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
22
• To solve problem using algorithms, we have to:
–READ and understand the problem
–THINK about different solutions to the
problem
–DESIGN an approach that will solve the
problem
–IMPLEMENT that design
–TEST to see if it works
23
If
needed
• The constructs used to build algorithms can be
described in two different ways:
1. Pseudo code
2. Flowchart
24
When the algorithm is written out as a well-thought
series of steps, it is called PSEUDO CODE
• It is written in easy to understand language (i.e.
ENGLISH)
• It is written very similar to the way that you would code
it into your 3rd Generation Language (i.e. C Language)
25
• 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
26
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
27
RESULT
• Mak Minah arrives in a great
mood ready to work J
RESULT
• Mak Minah arrives in not too
great a mood since she’s
soaking wet L
WAKE UP MAK MINAH 1
1. Get out of bed
2. Take off pyjamas
3. Take a shower
4. Get dressed
5. Eat breakfast
6. Drive to school
WAKE UP MAK MINAH 2
1. Get out of bed
2. Take off pyjamas
3. Get dressed
4. Take a shower
5. Eat breakfast
6. Drive to school
28
The order of
actions are very
important!
• 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”
29
• Example:
30
Process 2
Decision
Input Data
Process 1
Begin
Output Result
End
• BASIC SYMBOLS IN FLOW CHART
31
TERMINAL: Start/End of a program
PROCESSING: shows any mathematical
operation (e.g. addition, substraction, etc)
INPUT/OUTPUT: – where the user of the program
is asked for information (INPUT) or where the
program displays a result (OUTPUT)
DECISION: represents any action where the
computer is making a decision
Flow direction
Example 1
• Write an algorithm that display a message to the screen as
“Hello World!”.
32
• Begin
• Print Message
• End
Begin
Print “Hello World!”
End
Pseudo Code Flow Chart
Example 2:
Write a flowchart that calculates and prints the SUM of
two integers A and B.
• Begin
• Input A and B
• Calculate A + B
• Print result of SUM
• End
Begin
Input A, B
Calculate A + B
Print SUM
End
Pseudo Code Flow Chart
33
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”.
• Begin
• Input test1, test2 and test3
• Calculate average
• Print result of average
• End
Pseudo Code Flow Chart
35
Pseudo Code Flow Chart
• Begin
• Input test1, test2 and test3
• Calculate average
• If average >=60
• Display average &
“Passed”
• Otherwise
• Display average &
“Failed”
• End
END

More Related Content

Similar to 01 - Introduction to Computer and Algorithm (1).pdf (20)

PPTX
02 Algorithms and flowcharts - computers.pptx
arifaqazi2
 
PPTX
Algorithms - Introduction to computer programming
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 Introduction to computer components
BoonsaaMulataa
 
PPTX
Pj01 1-computer and programming fundamentals
SasidharaRaoMarrapu
 
PPTX
Computer programming
Mohamed Asarudeen
 
PDF
L1. Basic Programming Concepts.pdf
MMRF2
 
DOCX
Computing withBusiness Applications 1 Programming Log
LynellBull52
 
PDF
C progrmming
Shivam Singhal
 
PDF
6272 cnote
P Kiran Sree
 
PPTX
Csci101 lect00 introduction
Elsayed Hemayed
 
PPTX
Pf lec 01 intro
RajaKayani
 
PPT
Comp102 lec 1
Fraz Bakhsh
 
PPTX
Introduction to computer programming
Sangheethaa Sukumaran
 
PPT
computer programming introduction ppt.ppt
AlazarAlemayehu2
 
PPT
Introduction to Programming
Chaffey College
 
PPTX
Esc1.Introduction to Computerssssss.pptx
aljohnbasto4
 
PPTX
Introduction and history of Computers.pptx
ragustilo27
 
PPTX
Computer Programming - Lecture A
CMDLearning
 
PPTX
introduction to problem solving and programming
chaudhariresham6
 
PPT
C++ programming program design including data structures
Ahmad Idrees
 
02 Algorithms and flowcharts - computers.pptx
arifaqazi2
 
Algorithms - Introduction to computer programming
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 Introduction to computer components
BoonsaaMulataa
 
Pj01 1-computer and programming fundamentals
SasidharaRaoMarrapu
 
Computer programming
Mohamed Asarudeen
 
L1. Basic Programming Concepts.pdf
MMRF2
 
Computing withBusiness Applications 1 Programming Log
LynellBull52
 
C progrmming
Shivam Singhal
 
6272 cnote
P Kiran Sree
 
Csci101 lect00 introduction
Elsayed Hemayed
 
Pf lec 01 intro
RajaKayani
 
Comp102 lec 1
Fraz Bakhsh
 
Introduction to computer programming
Sangheethaa Sukumaran
 
computer programming introduction ppt.ppt
AlazarAlemayehu2
 
Introduction to Programming
Chaffey College
 
Esc1.Introduction to Computerssssss.pptx
aljohnbasto4
 
Introduction and history of Computers.pptx
ragustilo27
 
Computer Programming - Lecture A
CMDLearning
 
introduction to problem solving and programming
chaudhariresham6
 
C++ programming program design including data structures
Ahmad Idrees
 

Recently uploaded (13)

PDF
Be Quora-Famous in Your Niche Claim Your Spotlight Today
SocioCosmos
 
PDF
Developing frameworks for secure, privacy-preserving data collection and shar...
AJHSSR Journal
 
PPTX
J & T Web Solutions: Web Development and SEO Services Tailored for Your Business
J&T Web Solutions
 
PDF
Cryptomaster @mikehydes Medium Followers 21-06-25
Mike Hydes
 
PPTX
Writing Good 2023 Test Questions.pptx
Shwong11
 
PPTX
Impactofphysicalappearanceonsocialinteraction.pptx
PrincessCharizeRespe
 
PDF
𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳—Capcut Pro Crack For PC Latest 2025
utfefguu
 
PPTX
Zombie Virus Game.pptxxxxxxxxxxxxxxxxxxx
maryangeltuscano
 
PDF
Mike Hydes SlideShare Followers 21-06-25
Mike Hydes
 
PDF
Reddit Presence That Feels Organic Get Real Engagement
SocioCosmos
 
PPTX
Verity - SAP SoD Analysis Tool Simplify SAP SoD Analysis.pptx
bhanuprasadboppana
 
PPTX
The Essential Guide to Budgeting for Your Dental Marketing Campaign.pptx
bhanuprasadboppana
 
PDF
Cryptomaster @mikehydes Medium About Page
Mike Hydes
 
Be Quora-Famous in Your Niche Claim Your Spotlight Today
SocioCosmos
 
Developing frameworks for secure, privacy-preserving data collection and shar...
AJHSSR Journal
 
J & T Web Solutions: Web Development and SEO Services Tailored for Your Business
J&T Web Solutions
 
Cryptomaster @mikehydes Medium Followers 21-06-25
Mike Hydes
 
Writing Good 2023 Test Questions.pptx
Shwong11
 
Impactofphysicalappearanceonsocialinteraction.pptx
PrincessCharizeRespe
 
𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳—Capcut Pro Crack For PC Latest 2025
utfefguu
 
Zombie Virus Game.pptxxxxxxxxxxxxxxxxxxx
maryangeltuscano
 
Mike Hydes SlideShare Followers 21-06-25
Mike Hydes
 
Reddit Presence That Feels Organic Get Real Engagement
SocioCosmos
 
Verity - SAP SoD Analysis Tool Simplify SAP SoD Analysis.pptx
bhanuprasadboppana
 
The Essential Guide to Budgeting for Your Dental Marketing Campaign.pptx
bhanuprasadboppana
 
Cryptomaster @mikehydes Medium About Page
Mike Hydes
 
Ad

01 - Introduction to Computer and Algorithm (1).pdf

  • 1. KMJ16803 INTRODUCTION TO COMPUTER PROGRAMMING Introduction to Computer and Computer Programming Prof. Dr. Abdullah bin Chik Material Department Faculty of Chemical Engineering & Technology
  • 2. • Contributes 3 units: – 2 hours lectures (28 hours) – 2 hours labs (18 hours) • Main Objective: – Students can independently write, read, compile, debug and execute computer programs to solve problems, especially engineering related problems. COURSE INFORMATION
  • 3. COURSE OUTCOME CO1 Ability to assess the basic computer programming concepts and principles for engineering related programs. CO2 Ability to design simple computer programs to solve problems/issues in multidisciplinary engineering field. CO3 Ability to use coding software editor for coding, compiling, executing and debugging computer programs for related engineering programs.
  • 4. ASSESSMENT • 4 main components: – Midterm Test 1 20% – Midterm Test 2 20% – Assignments 20% – Quizzes 10% – Mini Project 30% • Assignments are assessed individually (in lab assignment) • Midterm tests are written test
  • 5. REFERENCES • Deitel & Deitel, “C How to Program”, Global Edition”, 8th Ed, Pearson , 2016. • Etter,, M.D, “Engineering Problem Solving with C ”, Global Edition”, 4th Ed, Pearson , 2012.
  • 6. NOTES • This course is NOT about the language per se, it is about analytical skills and to apply programming to solve problems. • Write C program in GNU compiler applications (CodeBlocks IDE) • Do early reading • Do not hesitate to ask during lecture sessions 6
  • 7. LECTURE OUTLINE 1. Introduction to Computer 2. Introduction to Computer Programming 3. Introduction to C Programming Language 7
  • 8. 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, and processing units § Software § Programs that run on a computer § Example: Operating System such as windows 10 and 11, Word processing packages such as MS Office 365
  • 10. 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
  • 11. 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: Hard disk, flash drive, memory card SD etc.
  • 12. 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
  • 13. 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.
  • 15. 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
  • 16. 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
  • 17. 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
  • 18. Problem Solving using Programming
  • 19. 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
  • 20. Properties of Well Designed Programs Well designed programs must : Correct and accurate Easy to understand Easy to maintain and update Efficient Reliable Flexible
  • 22. • 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 22
  • 23. • To solve problem using algorithms, we have to: –READ and understand the problem –THINK about different solutions to the problem –DESIGN an approach that will solve the problem –IMPLEMENT that design –TEST to see if it works 23 If needed
  • 24. • The constructs used to build algorithms can be described in two different ways: 1. Pseudo code 2. Flowchart 24
  • 25. When the algorithm is written out as a well-thought series of steps, it is called PSEUDO CODE • It is written in easy to understand language (i.e. ENGLISH) • It is written very similar to the way that you would code it into your 3rd Generation Language (i.e. C Language) 25
  • 26. • 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 26
  • 27. 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 27
  • 28. RESULT • Mak Minah arrives in a great mood ready to work J RESULT • Mak Minah arrives in not too great a mood since she’s soaking wet L WAKE UP MAK MINAH 1 1. Get out of bed 2. Take off pyjamas 3. Take a shower 4. Get dressed 5. Eat breakfast 6. Drive to school WAKE UP MAK MINAH 2 1. Get out of bed 2. Take off pyjamas 3. Get dressed 4. Take a shower 5. Eat breakfast 6. Drive to school 28 The order of actions are very important!
  • 29. • 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” 29
  • 30. • Example: 30 Process 2 Decision Input Data Process 1 Begin Output Result End
  • 31. • BASIC SYMBOLS IN FLOW CHART 31 TERMINAL: Start/End of a program PROCESSING: shows any mathematical operation (e.g. addition, substraction, etc) INPUT/OUTPUT: – where the user of the program is asked for information (INPUT) or where the program displays a result (OUTPUT) DECISION: represents any action where the computer is making a decision Flow direction
  • 32. Example 1 • Write an algorithm that display a message to the screen as “Hello World!”. 32 • Begin • Print Message • End Begin Print “Hello World!” End Pseudo Code Flow Chart
  • 33. Example 2: Write a flowchart that calculates and prints the SUM of two integers A and B. • Begin • Input A and B • Calculate A + B • Print result of SUM • End Begin Input A, B Calculate A + B Print SUM End Pseudo Code Flow Chart 33
  • 34. 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”.
  • 35. • Begin • Input test1, test2 and test3 • Calculate average • Print result of average • End Pseudo Code Flow Chart 35
  • 36. Pseudo Code Flow Chart • Begin • Input test1, test2 and test3 • Calculate average • If average >=60 • Display average & “Passed” • Otherwise • Display average & “Failed” • End
  • 37. END