[go: up one dir, main page]

0% found this document useful (0 votes)
89 views37 pages

BMS 201 Introduction PP

This document provides information about computer programming and programming languages. It discusses: - What a computer program and programming language are - Examples of popular programming languages like C++, Java, and HTML - The duties of a computer programmer like maintaining documentation and developing programs - The evolution of programming languages from machine languages to modern languages - Key aspects of different generations of languages like their readability and machine dependence - Steps in the program development process like designing algorithms and testing programs - The use of flowcharts to represent program logic in a visual way

Uploaded by

Brian Mutua
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views37 pages

BMS 201 Introduction PP

This document provides information about computer programming and programming languages. It discusses: - What a computer program and programming language are - Examples of popular programming languages like C++, Java, and HTML - The duties of a computer programmer like maintaining documentation and developing programs - The evolution of programming languages from machine languages to modern languages - Key aspects of different generations of languages like their readability and machine dependence - Steps in the program development process like designing algorithms and testing programs - The use of flowcharts to represent program logic in a visual way

Uploaded by

Brian Mutua
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

BMS 201

Computer
programming
Introduction
• Program - A precise sequence of steps that
computer obeys in order to solve a given
problem or perform a given task(s)
• Programming language – A special software
used to develop programs and applications
• Examples of programming languages - Basic,
COBOL, FORTRAN, C++, Java, Html, CSS
• Software – A collection of programs together
with their associated documentation
DUTIES OF A COMPUTER PROGRAMMER

• Trains software users within an organization


• Advises the management about software-related
matters
• Maintains updated documentations and records
about the corporate software
• Evaluates and modifies the existing software
• Designs and develops computer programs in a
business organization
• Handle users problem relating to a particular
program – user support
Generations of programming
languages
• First Generation – Machine Languages
• Second Generation – Assembly Languages
• Third Generation – Procedural or Problem
Oriented Languages
• Fourth Generation – Non Procedural
Language
• Fifth Generation – Natural Languages
First Generation – Machine Languages
• Used binary numbers to code programs
• 1100011001110011011100011001
• Programs were difficult to code and debug
• Programmers were required to memorize
memory codes
• 11001 11111 11110 – subtract - sub
• Executed directly without translation
• Programs were machine dependent
Second Generation – Assembly
Languages
• Replaced binary numbers with mnemonics to
code programs
• Mnemonics are symbolic program codes for
e.g. SUB for subtract and ADD for Address
• Programmers were required to memorize
memory codes
• Assemblers translated the programs into
machine language
• Programs were machine dependent
Third Generation – Procedural
Languages
• Greatly revolutionized programming
• Introduced English statements in
programming to make coding easy
• Programs were much easier to write and code
since programmers did not have to memorize
memory codes
• Programs were machine independent i.e.
could run on any type of computer
Third Generation – Procedural
Languages
• Introduced library of in built programs so all
programs did not have to be written from
scratch
• Used compilers and interpreters to translate
the programs into machine code
• Were procedural requiring precise sequence
of steps to perform tasks
• Classified into business, scientific and
multipurpose languages
Third Generation – Procedural
Languages
• Scientific languages - These are algebraic formula type
designed to meet typical scientific processing
requirement such as mathematical equations, iterative
processing, matrix manipulations etc. They include
FORTRAN – Formula Translator & APL -A programming
language.
• Business Oriented languages - are designed to be
effective tools for developing business information
systems. They include COBOL- Common business
oriented language & PG – report program generator.
• Multipurpose languages - are equally effective for
both scientific and business applications. They include
BASIC – Beginners All-purpose Symbolic Instruction
Code , Pascal – Named after a French mathematician
Blaise Pascal & C
Fourth Generation – Non procedural
Languages
• Non procedural - Do not require specific
sequence of steps to perform a given task.
• They are optimized for database manipulation
by requiring programmers to only provide
what is to be done and not how to do it.
• These greatly simplify programming.
• They included languages such as structured
query language SQL, query by example QBE
Fifth Generation – Natural languages
• These are advanced programming languages
that are not constrained by syntax, keywords
or specific programming vocabulary.
• Programmers can develop codes as naturally
as instructing a fellow human being to
perform a given tasks.
• Examples include object oriented languages
such as prolog, Java, C++, Perl, Python
Low level languages
• They are difficult to learn and to program in.
• They are far from human languages therefore
difficult to understand.
• They are fast in execution they need no or
minimum translation.
• They are difficult to modify, maintain and debug.
• They provide facility to write programs at
hardware level.
• They are machine dependent.
• They do not use library of built in codes
High level languages
• High-level languages are easy to learn and program in.
• They are near to human languages hence easy to
understand.
• Programs in high-level languages are slow in execution
they have to be translated into machine language.
• They are easy to modify, maintain and debug.
• High-level languages do not provide much facility at
hardware level.
• These languages are normally used to write application
programs.
• Machine independent
• Incorporate library of inbuilt functions
Types of Programming Languages
• C++
• COBOL
• JAVA
• CSS
• HTML
• VISUAL BASIC
• C
• PYTHON
Choice of programming language
• Type of application - commercial or scientific.
• Facilities required in the application – e.g.
speed of execution
• Availability of the language
• Availability of programmers
• Development costs
• Compatibility of the language
• Maintenance costs
STEPS IN PROGRAM DEVELOPMENT
• Generate program objectives/Problem Defn
• Design program / Algorithm Development
• Write the program Code/Coding
• Compile the code
• Execute or run the program
• Test and debug the program
• Maintenance and modification
• Documentation of Software
FLOWCHART DEVELOPMENT
• Flowcharts are Pictorial representation of the
program logic
• They help analyze the problem in more
effective way.
• Program flowcharts serve as a good program
documentation.
• Act as a guide during the systems analysis and
program development phase.
• The flowchart helps in debugging process.
• Provides means of communication with others
about the program
TYPES OF FLOW CHARTS
• Document flowcharts: showing a document
flow through a system
• Data flowcharts: showing data flows in a
system
• System flowcharts: showing controls at a
physical or resource level
• Program flowchart: showing the controls in a
program within a system
FLOWCHART SYMBOLS

• Start / Stop Symbol: this is depicted


using an elliptical or a rectangle with
rounded corners symbol. Shows the
beginning and end of the flowchart
• Diagram
FLOWCHART SYMBOLS
• Process / Computational Symbol:
This is represented using a
rectangular symbol; and the type of
the process or computation is
written inside the symbol
• Diagram
FLOWCHART SYMBOLS
• Input / Output Symbol: This is
depicted by a parallelogram-like
symbol as shown below. Captures
input and output into the flowchart
• Diagram
FLOWCHART SYMBOLS
• Decision Symbol: A decision –
making point is represented using a
diamond symbol. Used for making
selection or taking alternatives in
decision making
• Diagram
FLOWCHART SYMBOLS
• Connector Symbol: This is
represented with a circular symbol,
in which two parts of a program
flowchart join or connect.
• Diagram
FLOWCHART SYMBOLS
• Flow line: This is depicted by using a
straight line with an arrow at the
end. It shows the direction of flow in
a program.
• Diagram
FLOWCHART SYMBOLS
• Off – Page Connector: This symbol
enables a programmer to connect to
a flowchart that is continued into a
second or another page, and is
shown using a trapezium
• Diagram
GUIDELINES FOR DRAWING A
FLOWCHART
• In drawing a proper flowchart, all necessary
requirements should be listed out in logical
order.
• The flowchart should be clear, neat and easy
to follow. There should not be any room for
ambiguity in understanding the flowchart.
• The usual direction of the flow of a procedure
or system is from left to right or top to
bottom.
GUIDELINES FOR DRAWING A
FLOWCHART
• Only one flow line should come out from a
process symbol
• Only one flow line should enter a decision
symbol, but two or three flow lines, one for
each possible answer, should leave the
decision symbol.
• Only one flow line is used in conjunction with
terminal symbol.
1. Start
2. Product = 1
3. Count = 0
4. Input number Num
5. Sum = Sum + Num
6. Count = Count + 1
7. If Count < 35 then
8. Go to step 4
9. Else
10.Print Sum
11.End if
12.End
GUIDELINES FOR DRAWING A
FLOWCHART
• Write within standard symbols briefly.
• For complex flowchart use connector symbols
to reduce the number of flow lines.
• Avoid the intersection of flow lines
• Ensure that the flowchart has a logical start
and end.
• It is useful to test the validity of the flowchart
by passing through it with a simple test data.
Dry Running
FLOWCHARTING EXAMPLES
• Example 1
• Write an algorithm that can be used in
calculating and outputting the sum of the first
35 natural numbers
• Convert the algorithm mentioned in (a) above
into a flowchart
• Draw a flowchart to find the largest of three
numbers A, B and C.
1. Start
2. Sum = 0
3. Count = 0
4. Input number Num
5. Sum = Sum + Num
6. Count = Count + 1
7. If Count < 3 then
8. Go to step 4
9. Else
10.Print sum
11.End if
12.End
LIMITATIONS OF USING
FLOWCHARTS
• Complex logic: The program logic can be quite
complicated making the flowchart complex
and clumsy.
• Modifications: if alterations are required the
flowchart may require re-drawing completely.
• Reliability: the essentials of what is done can
easily be lost in the technical details of how it
is done.
Flowchart Exercises
• As a programmer, you are told to write a
program for computing the sum of the first 20
positive integers. The program is supposed to
output the sum after computing
• Write an algorithm for performing the above
task
• Rewrite the above algorithm using the
flowchart method
ALGORITHM
1. Start
2. Num = 0
3. Sum = 0
4. Sum = sum + num
5. Num = num + 1
6. If num <= 20 then
7. Go to step 4
8. Else
9. Print sum
10. Stop
Flow Chart Exercises
• A supermarket is planning to give discounts to its
customers based on the total costs of purchases made
by the customer. Discounts are given as follows:
• Total sales exceeding 5000/=, discount is 8%
• Sales greater than 3000/= and less than 5000/=,
discount is 5%
• Sales greater than or equal to 1500/= and less than
3000/=, discount is 2%
• Sales less than 1500/=, no discount
• Required: Develop an algorithm and draw up a
flowchart for a program that can be used to control this
process
ALGORITHM
1. Begin
2. Get Totsale (Total Sales)
3. If Totsale > 5000 then
4. Discount = 8% * Totsale
5. Elseif Totsale >=3000 and Totsale < 5000 then
6. Discount = 5% * Totsale
7. Elseif Totsale >=1500 and Totsale < 3000 then
8. Discount = 2% *Totsale
9. Else
10.Discount =0
11.Print Totsales
12.Print Discount
13.End

You might also like