SlideShare a Scribd company logo
1 of 65
Download to read offline
INF 130
STRUCTURED PROGRAMMING
(3 UNITS)
Instructor:
Dr. H. Bii / Mr. J Sigei
INTRODUCTION
ī‚ĸ Programming is a required skill today,
just like English and Maths.
ī‚ĸ It teaches a variety of skills that are
important in all kinds of professions:
ī‚— critical reading,
ī‚— analytical thinking,
ī‚— creative synthesis, and
ī‚— attention to detail.
ī‚ĸ It provides immediate feedback, leading
to exploration, experimentation, and self-
evaluation.
What is programming?
ī‚ĸ Process of coming up with computer
programs.
ī‚ĸ But what is a program?
ī‚— A PROGRAM is a set of instructions that a
computer can follow to do something.
ī‚ĸ Programming = process of coming up
with instructions that a computer can
follow to do something.
â€Ļ What is programming?
ī‚ĸ As a process, it involves:
īļUnderstanding a problem for which a
solution is required;
īļDesigning a solution;
īļWriting or coding the program in a
programming language;
īļTesting the code;
īļCorrecting any errors (debugging); and
īļMaintaining the program.
â€Ļ and Structured programming?
ī‚ĸ Programming that:
ī‚— Enforces a logical structure on the
program to make it efficient and easier to
maintain/modify.
ī‚— Implements modules (procedures /
functions), each fulfilling some function.
ī‚— Uses basic programming constructs -
sequence, selection and iteration (no goto
statements in „spaghetti code‟).
Programming Language
ī‚ĸ Programming requires a programming
language:
ī‚— a set of words, codes, and symbols that
allow a programmer to give instructions to
the computer.
ī‚— Each language has rules (or syntax) for
writing the instructions.
â€Ļ Programming Language
ī‚ĸ There are many programming
languages – so many! (like human
languages)
ī‚ĸ They may be classified (in many
ways, including) into THREE broad
categories:
īļ Machine Language;
īļ Assembly Language; and
īļ High-level Languages.
Their Evolution
Machine Language
ī‚ĸMade up of streams of 1s and 0s.
ī‚ĸPrograms written as series of 1s and
0s is said to be in machine language:
â€Ļ Machine Language
ī‚ĸ Machine language is the only language
understood by computer hardware.
ī‚ĸ Writing programs in machine language
is difficult and cumbersome –
instructions are difficult to remember.
The only language understood by computer
hardware is machine language.
â€Ļ Machine Language
ī‚ĸ Each computer has its own machine
language; rules of language differ from
one computer hardware to another.
ī‚ĸ Note: Machine language is also
referred to as First Generation
programming language.
First generation programming
Language; also low-level languages
Symbolic / Assembly Language
ī‚ĸ Developed in 1950s to reduce
programmers‟ burden – by Grace Murray
Hopper, US naval officer.
ī‚ĸ She developed the concept of a special
computer program that would convert
programs into machine language.
â€Ļ Symbolic / Assembly Language
ī‚ĸThe program mirrored the machine
languages using symbols, or mnemonics,
to represent the various machine
instructions.
ī‚ĸThe languages developed in this manner
were known as symbolic languages.
ī‚ĸAn assembler translates symbolic code
into machine language – thus Assembly
Language.
â€Ļ Assembly language
High-Level Languages
ī‚ĸ Symbolic language improved programming
efficiency, but still tedious and hardware focused.
ī‚ĸ High-level languages were developed to further
improve efficiency and change focus from
computer to the problem being solved.
ī‚ĸ High-level languages:
īƒ˜ produce portable programs;
īƒ˜ easier to learn;
īƒ˜ require less time to write;
īƒ˜ easier to maintain; and
īƒ˜ provide better documentation.
â€Ļ High-level language
Continued â€Ļ
â€Ļ example
ī‚ĸ Programs written in high-level languages have
English-like statements (and familiar math symbols)
and must be converted to machine language (1s and
0s).
ī‚ĸ The process of converting them is called compilation.
ī‚ĸ Examples of high-level languages are FORTRAN,
COBOL, C, BASIC, Pascal, ALGOL, and many
others.
Overview of some high-level languages
a) BASIC
ī‚ĸ Beginners‟ All-purpose Symbolic Instruction Code.
ī‚ĸ Developed by John Kemeny & Thomas Kurtz in
1964 – for beginners – easy to learn.
ī‚ĸ Example: 5 REM Program to compute sum of 10 numbers
10 LET s = 0
20 FOR i=1 TO 10
30 READ n
40 LET s = s + n
50 NEXT i
60 PRINT "The sum of the given numbers ="; s
70 DATA 4, 20, 15, 32, 48
80 DATA 12, 3, 9, 14, 44
100 END
b) Pascal
ī‚ĸ Introduced in 1971 by Niklaus Wirth in Zurich becoming
the first language to fully embody structured
programming concepts.
ī‚ĸ Example:
PROGRAM SUMNUM(INPUT, OUTPUT);
(* Program to Compute the sum of 10
numbers *)
(* Declaration of variables *)
VAR Sum, N :REAL;
VAR i :INTEGER;
BEGIN
Sum := 0;
FOR i := 1 TO 10 DO
BEGIN
READ (N);
Sum := Sum + N;
END;
WRITELN ('THE SUM OF GIVEN
NUMBERS =', SUM);
END
Assignment 1:
Read about and write short notes on the following
high-level languages:
ī‚— FORTRAN;
ī‚— COBOL;
ī‚— ADA;
ī‚— ALGOL; and
ī‚— PL/1.
System and Program Development
System Development
An old programming proverb:
Resist the temptation to code.
Note
Program Development
ī‚ĸMultistep process that requires that we:
īƒ˜Understand the problem – output
required; input available; steps to follow
in processing (algorithm).
īƒ˜Plan the logic of the solution (or
program). Three tools will help in this
task:
īƒ˜ Flowcharts;
īƒ˜ Pseudocode; and
īƒ˜ Structure charts.
â€Ļ Program Development
īƒ˜Code or write program statements in a
programming language e.g. BASIC, C,
Pascal. This may be done on paper.
īƒ˜Key the program into the computer
(use text editor).
īƒ˜Compile, test and debug the program.
īƒ˜Complete the documentation: charts,
listings, manuals.
... Programming Steps –
1) Understand the Problem
ī‚ĸRead the problem or talk to & listen to the
person who posed the problem.
ī‚ĸIdentify the problem inputs, outputs, and
any additional requirements or constraints:
ī‚— Inputs – data to work with;
ī‚— Outputs – desired results;
ī‚— Other Requirements/Constraints –
Relationships between variables, format of
results e.g. Table.
... Understand the Problem
Example:
Compute and display the total cost of
oranges given the weight of oranges
purchased and the cost per 1000g of
oranges.
... Understand the Problem
ī‚ĸFrom the problem, we identify:
Compute and display the total cost of
oranges given the weight of oranges
purchased and the cost per 1000g of
oranges.
Inputs:
ī‚ĸQuantity of oranges purchased (in Kgs);
ī‚ĸUnit cost of oranges (in Kshs.).
... Understand the Problem
ī‚ĸFrom the problem, we identify:
Compute and display the total cost of
oranges given the weight of oranges
purchased and the cost per 1000g of
oranges.
Outputs:
ī‚ĸTotal cost of oranges (in Kshs).
... Understand the Problem
Other requirements/constraints:
ī‚ĸTotal cost = Weight (Kgs) X Unit Cost
(Kshs).
ī‚ĸThe process we went thru (extracting
essential variables and their relationships)
is called ABSTRACTION.
... Understand the Problem
Exercises:
ī‚ĸ Read two numbers from the keyboard,
sum them up, and display the result.
ī‚ĸ Eldy surveyors want a program that
converts distances in miles to kilometres
and showing the result on screen.
2) Plan the logic of (Design) the solution
ī‚ĸInvolves developing a list of steps
(algorithm) to solve the problem.
ī‚ĸUsually the most difficult part of problem-
solving process.
ī‚ĸAs noted above, 3 tools are important
here:
ī‚ĸStructure charts;
ī‚ĸPseudocode; and
ī‚ĸFlowcharts.
Structure Chart
ī‚ĸAlso called hierarchy chart.
ī‚ĸIt shows the functional flow through a
program – parts (modules) of a program
and how they are related e.g.
â€Ļ structure chart
ī‚ĸIt is drawn before a program is written –
thus acting as an architectural blueprint –
more like a house plan.
ī‚ĸIn business world, once a structure chart
is completed, a structured walkthrough is
conducted – where a review panel is
taken through the structure to understand
how programmers plan to solve the
problem and attain the objectives they
set out to achieve.
â€Ļ structure chart
Question 1:
Develop a structure chart for a program
that is meant to obtain two numbers
from a user, multiply the numbers and
show the result on screen.
Solution?
Multiply 2
numbers
Program
Print ResultCalculate
Product
Input first &
second
numbers
Pseudocode
ī‚ĸ Is an English-like statement; part of program logic.
ī‚ĸ It describes what the program will do in precise
algorithmic detail e.g.
Pseudocode
English-like statements that follow a loosely defined syntax
and are used to convey the design of an algorithm.
Question 2:
Write a pseudocode for a program for calculating the
amount of tax (at 15% of value for property worth Kshs
100,000 and above, and 12% otherwise) of a property.
Assume that the user wants to determine taxes for more
than one property.
Question 3:
Write a pseudocode for a program for calculating
the cost of flooring the living areas (slide 33).
Reading:
Do a literature search in the Library or on the Internet about pseudocode
as a design and documentation tool. Read and attempt the questions
above.
Flowchart
ī‚ĸProgram design tool that uses standard
graphical symbols to represent logical
flow of data thru a function/program.
ī‚ĸIts primary purpose is to show the design
of an algorithm.
â€Ļ Flowchart
ī‚ĸIt frees a programmer from the syntax and
details of programming to concentrate on
details of the problem to be solved.
ī‚ĸIt gives a pictorial representation of an
algorithm – helps one to think of a
problem pictorially.
example Startv
Stop
Read
Length
Read
Width
Print Area
Calculate
Area = Length X
Width
example
Flowcharting Symbols:
Two basic categories:
1) Auxiliary symbols
īƒ˜ enhance readability or functionality of a
flowchart.
īƒ˜ They do not directly show instructions or
commands.
a) Terminators:
START STOP
b) Flow lines:
Rule: One entry/exit!
Rule: Start/Stop has one
Exiting/entering line!
â€Ļ auxiliary symbols
c) Connectors:
n
Circle with number
in it.
2) Primary Symbols:
ī‚ĸ Show instructions or actions needed a problem presented in
the algorithm.
ī‚ĸ They show all three structured programming constructs:
sequence, decision, and repetition.
a) Sequence Symbols:
Sum ← x + y
i) Assignment
Statement:
ii) Input/Output
Statement:
Read x
Startv
Stop
Read
Length
Read
Width
Print Area
Calculate
Area = Length X
Width
â€Ļ sequence symbols:
iii) Module-call statement:
AVRG(ave, a, b, c)
Startv
Stop
Read (a)
Read (b)
Print
Average
Read (c)
AVRG(ave, a, b, c)
Flowchart for this
is elsewhere (below)
AVRG(rslt, x, y, z)v
Return
sum ← x + y + z
rslt ← sum/3
b) Selection statement symbols
ī‚ĸ Those for specifying conditional statements (that
allow execution of selected statements and
skipping of others).
ī‚ĸ There are 2 selection statements (decisions):
ī‚ĸ Two-way selection;
ī‚ĸ Multiway selection.
Condition Number > 10
TF
T – to the right;
F – to the left;
NB: Not good practice to have any to bottom!
2-way:
â€Ļ selection Startv
Stop
Read (a)
a > 10
TF
Write
(newnum)
newnum ← a - 10
NOTE: Only one statement (or
null) in each branch is allowed & it
may be a compound statement
â€Ļ selection
Multiway selection:
Example (multiway selection)
Question 4:
Design an algorithm (flowchart) that reads an integer. If
the integer value is greater than 10, it subtracts 10 and
writes the original number and the result. If the number
is less than 10, it displays the message “That number is
less than 10”.
Question 5:
Design a flowchart for a program that reads a mark
between 0 and 100 and prints a corresponding letter
grade.
c) Looping Statements symbols
ī‚ĸ Iteration/repetition (for, while, do..while)
a) for
- Counting loop.
- pre-test, so body may
never be executed.
- good when number of
times to loop is known.
â€Ļ for loop actions
Question 6:
Design a flowchart (or algorithm) for a program that
reads 20 numbers and print their sum.
? answerâ€Ļ
b) while
â€ĸ Not a counting loop;
â€ĸAlso pre-test loop – body
may not be executed.
â€ĸGood when number of
times to loop is not known.
Question 7:
Design a flowchart for a program that reads numbers from
the keyboard and prints their total. We don‟t know how
many numbers the user will input. However, all numbers
are positive numbers.
NOTE: first number is
read before the loop (i.e.
priming the loop)
c) do...while
â€ĸ this is a post-test loop i.e. the
condition is tested at the end of
the loop.
â€ĸBody of the loop is executed at
least once
Question 8:
Design a flowchart for a program that reads and
processes numbers between 1 and 5. How it processes
the numbers is not important at this stage.
(num > 1)
&& (num < 5)
So far in Program Development â€Ļ
ī‚ĸ Multistep process that requires that we:
īƒ˜ Understand the problem – output required; input
available; steps to follow in processing (algorithm).
īƒ˜ Plan the logic of the solution (or program). Three tools
will help in this task:
īƒ˜ Flowcharts;
īƒ˜ Pseudocode; and
īƒ˜ Structure charts.
īƒ˜ Code or write program statements in a programming
language e.g. BASIC, C, Pascal. This may be done on
paper.
īƒ˜ Key the program into the computer (use text editor).
īƒ˜ Test and debug the program.
īƒ˜ Complete the documentation: charts, listings, manuals.
Exercises
Write a pseudocode and develop a flowchart for each of
the following problems:
1) Calculate the circumference and area of a circle (PI =
3.142).
2) Compute and display the letter grade of a student‟s
mark in a certain course.
3) Compute and print the net pay of an employee given
the number of hours worked and the hourly rate of
pay.
4) Convert the temperature given in degrees fahrenheit
to degrees celcius given that:
Degrees Celcius = (Degrees Fahrenheit – 32) * 5/9
Coding
ī‚ĸ Writing instructions in a programming language –
high-level language.
ī‚ĸ So we need to learn the language, its structure and
syntax.
ī‚ĸ Choice: C
structured programming Introduction to c fundamentals

More Related Content

What's hot

Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming ConceptsJussi Pohjolainen
 
Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.netMUKALU STEVEN
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingABHISHEK fulwadhwa
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - AbstractionMichael Heron
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Md. Imran Hossain Showrov
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming conceptssalmankhan570
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1REHAN IJAZ
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++Bhavik Vashi
 
Java Data Types
Java Data TypesJava Data Types
Java Data TypesSpotle.ai
 
Chapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingChapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingAbdul Shah
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++Nilesh Dalvi
 
What is programming what are its benefits
What is programming  what are its benefits What is programming  what are its benefits
What is programming what are its benefits Vijay Singh Khatri
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocodeAsha Sari
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 

What's hot (20)

Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.net
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - Abstraction
 
Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language Lecture 5 - Structured Programming Language
Lecture 5 - Structured Programming Language
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Chapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solvingChapter #1 overview of programming and problem solving
Chapter #1 overview of programming and problem solving
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
What is programming what are its benefits
What is programming  what are its benefits What is programming  what are its benefits
What is programming what are its benefits
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 

Similar to structured programming Introduction to c fundamentals

Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithmshccit
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
Comso c++
Comso c++Comso c++
Comso c++Mi L
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c languageRai University
 
Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12Sehrish Rafiq
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageRai University
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageRai University
 
Computer program, computer languages, computer software
Computer program, computer languages, computer softwareComputer program, computer languages, computer software
Computer program, computer languages, computer softwareSweta Kumari Barnwal
 
introduction to c language
 introduction to c language introduction to c language
introduction to c languageRai University
 
Programming in c
Programming in cProgramming in c
Programming in cindra Kishor
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageRai University
 
Intro1
Intro1Intro1
Intro1phanleson
 
notes on Programming fundamentals
notes on Programming fundamentals notes on Programming fundamentals
notes on Programming fundamentals ArghodeepPaul
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 

Similar to structured programming Introduction to c fundamentals (20)

Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
Lecture 1-3.ppt
Lecture 1-3.pptLecture 1-3.ppt
Lecture 1-3.ppt
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithms
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
 
C programme presentation
C programme presentationC programme presentation
C programme presentation
 
Comso c++
Comso c++Comso c++
Comso c++
 
Diploma ii cfpc u-1 introduction to c language
Diploma ii  cfpc u-1 introduction to c languageDiploma ii  cfpc u-1 introduction to c language
Diploma ii cfpc u-1 introduction to c language
 
Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12Introduction to Computers Lecture # 12
Introduction to Computers Lecture # 12
 
Btech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c languageBtech i pic u-1 introduction to c language
Btech i pic u-1 introduction to c language
 
Bsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c languageBsc cs i pic u-1 introduction to c language
Bsc cs i pic u-1 introduction to c language
 
Computer program, computer languages, computer software
Computer program, computer languages, computer softwareComputer program, computer languages, computer software
Computer program, computer languages, computer software
 
introduction to c language
 introduction to c language introduction to c language
introduction to c language
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Mca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c languageMca i pic u-1 introduction to c language
Mca i pic u-1 introduction to c language
 
Intro1
Intro1Intro1
Intro1
 
notes on Programming fundamentals
notes on Programming fundamentals notes on Programming fundamentals
notes on Programming fundamentals
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 

More from OMWOMA JACKSON

Sytem analysis and design take away cat
Sytem analysis and design take away catSytem analysis and design take away cat
Sytem analysis and design take away catOMWOMA JACKSON
 
L11 system maintenance
L11 system maintenanceL11 system maintenance
L11 system maintenanceOMWOMA JACKSON
 
L9 quality assurance and documentation
L9 quality assurance and documentationL9 quality assurance and documentation
L9 quality assurance and documentationOMWOMA JACKSON
 
L10 system implementation
L10 system implementationL10 system implementation
L10 system implementationOMWOMA JACKSON
 
Technologies in booktrade
Technologies in booktradeTechnologies in booktrade
Technologies in booktradeOMWOMA JACKSON
 
Issues in booktrade
Issues in booktradeIssues in booktrade
Issues in booktradeOMWOMA JACKSON
 
Ins 206 introduction to book i
Ins 206 introduction to book iIns 206 introduction to book i
Ins 206 introduction to book iOMWOMA JACKSON
 
L8 entity relationship
L8 entity relationshipL8 entity relationship
L8 entity relationshipOMWOMA JACKSON
 
Let us c yashwant kanetkar(1)
Let us c   yashwant kanetkar(1)Let us c   yashwant kanetkar(1)
Let us c yashwant kanetkar(1)OMWOMA JACKSON
 
Kenya vision 2030
Kenya vision 2030Kenya vision 2030
Kenya vision 2030OMWOMA JACKSON
 
Why records management
Why records managementWhy records management
Why records managementOMWOMA JACKSON
 
Why records management is important
Why records management is importantWhy records management is important
Why records management is importantOMWOMA JACKSON
 
Records management
Records managementRecords management
Records managementOMWOMA JACKSON
 

More from OMWOMA JACKSON (17)

Sytem analysis and design take away cat
Sytem analysis and design take away catSytem analysis and design take away cat
Sytem analysis and design take away cat
 
Ordering 4
Ordering 4Ordering 4
Ordering 4
 
L11 system maintenance
L11 system maintenanceL11 system maintenance
L11 system maintenance
 
L9 quality assurance and documentation
L9 quality assurance and documentationL9 quality assurance and documentation
L9 quality assurance and documentation
 
L10 system implementation
L10 system implementationL10 system implementation
L10 system implementation
 
Technologies in booktrade
Technologies in booktradeTechnologies in booktrade
Technologies in booktrade
 
Issues in booktrade
Issues in booktradeIssues in booktrade
Issues in booktrade
 
Ins 206 introduction to book i
Ins 206 introduction to book iIns 206 introduction to book i
Ins 206 introduction to book i
 
L8 entity relationship
L8 entity relationshipL8 entity relationship
L8 entity relationship
 
Let us c yashwant kanetkar(1)
Let us c   yashwant kanetkar(1)Let us c   yashwant kanetkar(1)
Let us c yashwant kanetkar(1)
 
Kenya vision 2030
Kenya vision 2030Kenya vision 2030
Kenya vision 2030
 
Why records management
Why records managementWhy records management
Why records management
 
Why records management is important
Why records management is importantWhy records management is important
Why records management is important
 
Records management
Records managementRecords management
Records management
 
E-Business
E-BusinessE-Business
E-Business
 
E Business
E BusinessE Business
E Business
 
E business
E businessE business
E business
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
đŸŦ The future of MySQL is Postgres 🐘
đŸŦ  The future of MySQL is Postgres   🐘đŸŦ  The future of MySQL is Postgres   🐘
đŸŦ The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
đŸŦ The future of MySQL is Postgres 🐘
đŸŦ  The future of MySQL is Postgres   🐘đŸŦ  The future of MySQL is Postgres   🐘
đŸŦ The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

structured programming Introduction to c fundamentals

  • 1. INF 130 STRUCTURED PROGRAMMING (3 UNITS) Instructor: Dr. H. Bii / Mr. J Sigei
  • 2. INTRODUCTION ī‚ĸ Programming is a required skill today, just like English and Maths. ī‚ĸ It teaches a variety of skills that are important in all kinds of professions: ī‚— critical reading, ī‚— analytical thinking, ī‚— creative synthesis, and ī‚— attention to detail. ī‚ĸ It provides immediate feedback, leading to exploration, experimentation, and self- evaluation.
  • 3. What is programming? ī‚ĸ Process of coming up with computer programs. ī‚ĸ But what is a program? ī‚— A PROGRAM is a set of instructions that a computer can follow to do something. ī‚ĸ Programming = process of coming up with instructions that a computer can follow to do something.
  • 4. â€Ļ What is programming? ī‚ĸ As a process, it involves: īļUnderstanding a problem for which a solution is required; īļDesigning a solution; īļWriting or coding the program in a programming language; īļTesting the code; īļCorrecting any errors (debugging); and īļMaintaining the program.
  • 5. â€Ļ and Structured programming? ī‚ĸ Programming that: ī‚— Enforces a logical structure on the program to make it efficient and easier to maintain/modify. ī‚— Implements modules (procedures / functions), each fulfilling some function. ī‚— Uses basic programming constructs - sequence, selection and iteration (no goto statements in „spaghetti code‟).
  • 6. Programming Language ī‚ĸ Programming requires a programming language: ī‚— a set of words, codes, and symbols that allow a programmer to give instructions to the computer. ī‚— Each language has rules (or syntax) for writing the instructions.
  • 7. â€Ļ Programming Language ī‚ĸ There are many programming languages – so many! (like human languages) ī‚ĸ They may be classified (in many ways, including) into THREE broad categories: īļ Machine Language; īļ Assembly Language; and īļ High-level Languages.
  • 9. Machine Language ī‚ĸMade up of streams of 1s and 0s. ī‚ĸPrograms written as series of 1s and 0s is said to be in machine language:
  • 10. â€Ļ Machine Language ī‚ĸ Machine language is the only language understood by computer hardware. ī‚ĸ Writing programs in machine language is difficult and cumbersome – instructions are difficult to remember. The only language understood by computer hardware is machine language.
  • 11. â€Ļ Machine Language ī‚ĸ Each computer has its own machine language; rules of language differ from one computer hardware to another. ī‚ĸ Note: Machine language is also referred to as First Generation programming language. First generation programming Language; also low-level languages
  • 12. Symbolic / Assembly Language ī‚ĸ Developed in 1950s to reduce programmers‟ burden – by Grace Murray Hopper, US naval officer. ī‚ĸ She developed the concept of a special computer program that would convert programs into machine language.
  • 13. â€Ļ Symbolic / Assembly Language ī‚ĸThe program mirrored the machine languages using symbols, or mnemonics, to represent the various machine instructions. ī‚ĸThe languages developed in this manner were known as symbolic languages. ī‚ĸAn assembler translates symbolic code into machine language – thus Assembly Language.
  • 15. High-Level Languages ī‚ĸ Symbolic language improved programming efficiency, but still tedious and hardware focused. ī‚ĸ High-level languages were developed to further improve efficiency and change focus from computer to the problem being solved. ī‚ĸ High-level languages: īƒ˜ produce portable programs; īƒ˜ easier to learn; īƒ˜ require less time to write; īƒ˜ easier to maintain; and īƒ˜ provide better documentation.
  • 17. â€Ļ example ī‚ĸ Programs written in high-level languages have English-like statements (and familiar math symbols) and must be converted to machine language (1s and 0s). ī‚ĸ The process of converting them is called compilation. ī‚ĸ Examples of high-level languages are FORTRAN, COBOL, C, BASIC, Pascal, ALGOL, and many others.
  • 18. Overview of some high-level languages a) BASIC ī‚ĸ Beginners‟ All-purpose Symbolic Instruction Code. ī‚ĸ Developed by John Kemeny & Thomas Kurtz in 1964 – for beginners – easy to learn. ī‚ĸ Example: 5 REM Program to compute sum of 10 numbers 10 LET s = 0 20 FOR i=1 TO 10 30 READ n 40 LET s = s + n 50 NEXT i 60 PRINT "The sum of the given numbers ="; s 70 DATA 4, 20, 15, 32, 48 80 DATA 12, 3, 9, 14, 44 100 END
  • 19. b) Pascal ī‚ĸ Introduced in 1971 by Niklaus Wirth in Zurich becoming the first language to fully embody structured programming concepts. ī‚ĸ Example: PROGRAM SUMNUM(INPUT, OUTPUT); (* Program to Compute the sum of 10 numbers *) (* Declaration of variables *) VAR Sum, N :REAL; VAR i :INTEGER; BEGIN Sum := 0; FOR i := 1 TO 10 DO BEGIN READ (N); Sum := Sum + N; END; WRITELN ('THE SUM OF GIVEN NUMBERS =', SUM); END
  • 20. Assignment 1: Read about and write short notes on the following high-level languages: ī‚— FORTRAN; ī‚— COBOL; ī‚— ADA; ī‚— ALGOL; and ī‚— PL/1.
  • 21. System and Program Development
  • 22.
  • 23. System Development An old programming proverb: Resist the temptation to code. Note
  • 24. Program Development ī‚ĸMultistep process that requires that we: īƒ˜Understand the problem – output required; input available; steps to follow in processing (algorithm). īƒ˜Plan the logic of the solution (or program). Three tools will help in this task: īƒ˜ Flowcharts; īƒ˜ Pseudocode; and īƒ˜ Structure charts.
  • 25. â€Ļ Program Development īƒ˜Code or write program statements in a programming language e.g. BASIC, C, Pascal. This may be done on paper. īƒ˜Key the program into the computer (use text editor). īƒ˜Compile, test and debug the program. īƒ˜Complete the documentation: charts, listings, manuals.
  • 26. ... Programming Steps – 1) Understand the Problem ī‚ĸRead the problem or talk to & listen to the person who posed the problem. ī‚ĸIdentify the problem inputs, outputs, and any additional requirements or constraints: ī‚— Inputs – data to work with; ī‚— Outputs – desired results; ī‚— Other Requirements/Constraints – Relationships between variables, format of results e.g. Table.
  • 27. ... Understand the Problem Example: Compute and display the total cost of oranges given the weight of oranges purchased and the cost per 1000g of oranges.
  • 28. ... Understand the Problem ī‚ĸFrom the problem, we identify: Compute and display the total cost of oranges given the weight of oranges purchased and the cost per 1000g of oranges. Inputs: ī‚ĸQuantity of oranges purchased (in Kgs); ī‚ĸUnit cost of oranges (in Kshs.).
  • 29. ... Understand the Problem ī‚ĸFrom the problem, we identify: Compute and display the total cost of oranges given the weight of oranges purchased and the cost per 1000g of oranges. Outputs: ī‚ĸTotal cost of oranges (in Kshs).
  • 30. ... Understand the Problem Other requirements/constraints: ī‚ĸTotal cost = Weight (Kgs) X Unit Cost (Kshs). ī‚ĸThe process we went thru (extracting essential variables and their relationships) is called ABSTRACTION.
  • 31. ... Understand the Problem Exercises: ī‚ĸ Read two numbers from the keyboard, sum them up, and display the result. ī‚ĸ Eldy surveyors want a program that converts distances in miles to kilometres and showing the result on screen.
  • 32. 2) Plan the logic of (Design) the solution ī‚ĸInvolves developing a list of steps (algorithm) to solve the problem. ī‚ĸUsually the most difficult part of problem- solving process. ī‚ĸAs noted above, 3 tools are important here: ī‚ĸStructure charts; ī‚ĸPseudocode; and ī‚ĸFlowcharts.
  • 33. Structure Chart ī‚ĸAlso called hierarchy chart. ī‚ĸIt shows the functional flow through a program – parts (modules) of a program and how they are related e.g.
  • 34. â€Ļ structure chart ī‚ĸIt is drawn before a program is written – thus acting as an architectural blueprint – more like a house plan. ī‚ĸIn business world, once a structure chart is completed, a structured walkthrough is conducted – where a review panel is taken through the structure to understand how programmers plan to solve the problem and attain the objectives they set out to achieve.
  • 35. â€Ļ structure chart Question 1: Develop a structure chart for a program that is meant to obtain two numbers from a user, multiply the numbers and show the result on screen.
  • 37. Pseudocode ī‚ĸ Is an English-like statement; part of program logic. ī‚ĸ It describes what the program will do in precise algorithmic detail e.g. Pseudocode English-like statements that follow a loosely defined syntax and are used to convey the design of an algorithm.
  • 38. Question 2: Write a pseudocode for a program for calculating the amount of tax (at 15% of value for property worth Kshs 100,000 and above, and 12% otherwise) of a property. Assume that the user wants to determine taxes for more than one property. Question 3: Write a pseudocode for a program for calculating the cost of flooring the living areas (slide 33). Reading: Do a literature search in the Library or on the Internet about pseudocode as a design and documentation tool. Read and attempt the questions above.
  • 39. Flowchart ī‚ĸProgram design tool that uses standard graphical symbols to represent logical flow of data thru a function/program. ī‚ĸIts primary purpose is to show the design of an algorithm.
  • 40. â€Ļ Flowchart ī‚ĸIt frees a programmer from the syntax and details of programming to concentrate on details of the problem to be solved. ī‚ĸIt gives a pictorial representation of an algorithm – helps one to think of a problem pictorially.
  • 43. Flowcharting Symbols: Two basic categories: 1) Auxiliary symbols īƒ˜ enhance readability or functionality of a flowchart. īƒ˜ They do not directly show instructions or commands. a) Terminators: START STOP b) Flow lines: Rule: One entry/exit! Rule: Start/Stop has one Exiting/entering line!
  • 44. â€Ļ auxiliary symbols c) Connectors: n Circle with number in it.
  • 45.
  • 46. 2) Primary Symbols: ī‚ĸ Show instructions or actions needed a problem presented in the algorithm. ī‚ĸ They show all three structured programming constructs: sequence, decision, and repetition. a) Sequence Symbols: Sum ← x + y i) Assignment Statement: ii) Input/Output Statement: Read x
  • 48. â€Ļ sequence symbols: iii) Module-call statement: AVRG(ave, a, b, c) Startv Stop Read (a) Read (b) Print Average Read (c) AVRG(ave, a, b, c) Flowchart for this is elsewhere (below)
  • 49. AVRG(rslt, x, y, z)v Return sum ← x + y + z rslt ← sum/3
  • 50. b) Selection statement symbols ī‚ĸ Those for specifying conditional statements (that allow execution of selected statements and skipping of others). ī‚ĸ There are 2 selection statements (decisions): ī‚ĸ Two-way selection; ī‚ĸ Multiway selection. Condition Number > 10 TF T – to the right; F – to the left; NB: Not good practice to have any to bottom! 2-way:
  • 51. â€Ļ selection Startv Stop Read (a) a > 10 TF Write (newnum) newnum ← a - 10 NOTE: Only one statement (or null) in each branch is allowed & it may be a compound statement
  • 54. Question 4: Design an algorithm (flowchart) that reads an integer. If the integer value is greater than 10, it subtracts 10 and writes the original number and the result. If the number is less than 10, it displays the message “That number is less than 10”. Question 5: Design a flowchart for a program that reads a mark between 0 and 100 and prints a corresponding letter grade.
  • 55. c) Looping Statements symbols ī‚ĸ Iteration/repetition (for, while, do..while) a) for - Counting loop. - pre-test, so body may never be executed. - good when number of times to loop is known.
  • 56. â€Ļ for loop actions Question 6: Design a flowchart (or algorithm) for a program that reads 20 numbers and print their sum.
  • 58. b) while â€ĸ Not a counting loop; â€ĸAlso pre-test loop – body may not be executed. â€ĸGood when number of times to loop is not known. Question 7: Design a flowchart for a program that reads numbers from the keyboard and prints their total. We don‟t know how many numbers the user will input. However, all numbers are positive numbers.
  • 59. NOTE: first number is read before the loop (i.e. priming the loop)
  • 60. c) do...while â€ĸ this is a post-test loop i.e. the condition is tested at the end of the loop. â€ĸBody of the loop is executed at least once Question 8: Design a flowchart for a program that reads and processes numbers between 1 and 5. How it processes the numbers is not important at this stage.
  • 61. (num > 1) && (num < 5)
  • 62. So far in Program Development â€Ļ ī‚ĸ Multistep process that requires that we: īƒ˜ Understand the problem – output required; input available; steps to follow in processing (algorithm). īƒ˜ Plan the logic of the solution (or program). Three tools will help in this task: īƒ˜ Flowcharts; īƒ˜ Pseudocode; and īƒ˜ Structure charts. īƒ˜ Code or write program statements in a programming language e.g. BASIC, C, Pascal. This may be done on paper. īƒ˜ Key the program into the computer (use text editor). īƒ˜ Test and debug the program. īƒ˜ Complete the documentation: charts, listings, manuals.
  • 63. Exercises Write a pseudocode and develop a flowchart for each of the following problems: 1) Calculate the circumference and area of a circle (PI = 3.142). 2) Compute and display the letter grade of a student‟s mark in a certain course. 3) Compute and print the net pay of an employee given the number of hours worked and the hourly rate of pay. 4) Convert the temperature given in degrees fahrenheit to degrees celcius given that: Degrees Celcius = (Degrees Fahrenheit – 32) * 5/9
  • 64. Coding ī‚ĸ Writing instructions in a programming language – high-level language. ī‚ĸ So we need to learn the language, its structure and syntax. ī‚ĸ Choice: C