Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

321EE3

Computer
Programming
Chapter 0: Algorithmic Development
(C++: The Object-Oriented Programming Language)

Just one small positive thought in the morning can change your whole day. – …
321EE3 Computer Programming
• Course Contents
• 1. Algorithmic Development: Techniques of problem solving
• 2. Algorithmic Development: Flowcharting, decision table
• 3. Algorithmic Development: Structured Programming concepts
• 4. Basics of C++: Structure of C++ program, keywords and identifiers
• 5. Basics of C++: Constants, variables, data types and type conversion.
• 6. Basics of C++: Types of operators and expressions
• 7. Basics of C++: Input and output functions in C++.
• 8. Basics of C++: Decision Statement: IF-ELSE statement, break, continue, go-to, switch () case and nested
IF statement.
• 9. Basics of C++: Loop Control Statements: For loop, While loop, Do-while loop and nested loops.
• 10. Functions, Arrays, Pointers and Data structures.
• 11. Classes, inheritance and Polymorphism.
• Textbook(s):
• 1. Object Oriented Programming in C++ by Robert Lafore, Pearson, 4th Edition, (2013)
• 2. C++ How to Program, 7/e. By Paul and Harvey Deitel. 2010
• 3. Programming and Problem Solving with C++. By Nell Dale and Chip Weems. Jones & Bartlett Learning;
5 edition (February 27, 2009).
The homepage of Bjarne Stroustrup, the inventor of C++: http://www.research.att.com/~bs
A C++ online tutorial: http://www.cplusplus.com/doc/tutorial/
The C++ FAQ: http://www.parashift.com/c++-faq-lite
www.geeksforgeeks.org/basic-concepts-of-object-oriented-programming
www.tutorialspoint.com/cplusplus/cpp_object_oriented.htm
Online C++ Compiler: https://ide.codingblocks.com/ https://archive.org/details/EBalagurusamyObjectOrientedProgrammingWithC
Contents
• 1. Algorithmic Development: Techniques of Problem Solving
• 2. Algorithmic Development: Flowcharting, Decision Table
• 3. Algorithmic Development: Structured Programming Concepts
Algorithmic Development: Techniques of
Problem Solving
• Algorithm
• An algorithm is a set of instructions for solving a
problem or accomplishing a task. Every
computerized device uses algorithms to perform its
functions in the form of hardware- or software-
based routines.
• Example: Algorithms are all around us. Common examples
includes; the recipe for baking a cake, the method we use
to solve a long division problem, the process of doing
laundry, and the functionality of a search engine, etc.
• Types of Algorithms: Recursive Algorithm, Divide and
Conquer Algorithm, Dynamic Programming Algorithm,
Greedy Algorithm, Brute Force Algorithm, Backtracking
Algorithm, etc.
Algorithmic Development: Techniques of
Problem Solving (Contd)
• Steps for Designing & Analyzing an Algorithm
• Understand the Problem
• Read the Problem
• Ask Questions
• Find and Decide the Range of Inputs
• Make Decision
• Capacities of Computational Devices – Sequential & Parallel
• Select Problem Solving Methods – Exact & Approximations
• Data Structures
• Algorithmic Strategies
• Design an Algorithm
• Natural Language
• Pseudocode
• Flowchart
• Prove Correctness
• Verification
• Validation
• Analyze the Algorithm
• Time Complexity
• Space Complexity
• Simplicity
• Generality
• Code the Algorithm
• Suitable Programming Language
• Writing Optimized Code
Algorithmic Development: Techniques of
Problem Solving (Contd)
• Important Problem-Solving Types
• Sorting
• Stable & In-Place Property
• Searching
• Search Key
• Numerical Problems
• Mathematical & System of Equations
• Geometric Problems
• Computer Graphics & Robotics
• Combinatorial Problems
• Permutations & Combinations
• Graph Problems
• Traversal Algorithms, Topological Sorting
• String Processing Problems
• Pattern Matching Algorithm
Algorithmic Development: Flowcharting,
Decision Table (Contd)
• Decision Table
• Decision tables are a concise visual representation for specifying which actions to perform depending on given conditions.
• A decision table is a graphical way to map conditions against actions. It expresses the fact that certain actions are to be performed
only if certain conditions (or combination thereof) are satisfied.
• Example: In a Limited Entry Decision Table, find when the Order is ACCEPTED and REJECTED form the following Decision
Table.
• Rules: Any two rows which have identical entries, except for one condition row which contain a Y and N may be consolidated into one row which
contains a dash (-) in place of Y and N.

https://www.youtube.com/watch?v=zHokvz4fRGY
Algorithmic Development: Flowcharting,
Decision Table (Contd)

Example: Decision Table: A Limited Entry Decision Table.


Rules: Any two rows which have identical entries, except for one condition row which contain a Y and N may be consolidated into
one row which contains a dash (-) in place of Y and N.
Answer (Result): The resulting table, only reject the order when
1. the customer has exceeded the credit limits and
2. they don’t have special clearance.
otherwise (else) we will accept the order.
Algorithmic Development: Flowcharting,
Decision Table (Contd)
• FlowChart
• Flowchart is the Graphical Representation of an algorithm.
It is used to show all the steps of an algorithm in a
sequence pictorially.
• An algorithm may be converted to a flowchart.
• The flowchart is then converted into a program written in
any programming language.
• Advantages of Flowcharts
• 1. Flowchart represents an algorithm in graphical symbols.
• 2. It shows the steps of an algorithm in an easy way.
• 3. It is used to understand the flow of the program
graphically.
• 4. Flowchart can be easier and more effective to
understand the logic of the given program instantly.
• 5. A flowchart will be helpful to the programmer during
coding / program development phase.
Algorithmic Development: Flowcharting,
Decision Table (Contd)
• FlowChart (Contd)
• Commonly Used Symbols To Draw a Flowchart
• So, after reading the benefits of using Flowcharts in Computer programming, we will learn how to draw a flow chart.
Following are the common symbols used in Flowchart:
• 1. Start/End
• Oval symbol is used to represent the start or end of the flowchart. Every program has a Start and End. So, we will add an Oval
symbol with caption "Start" in the beginning of each flow chart. Similarly, we will place an Oval symbol with the tag "End" or "Stop"
at the end of every flow chart.
• 2. Input/Output
• Parallelogram symbol is used to represent an input or output step. So, if we wish to input the value of a variable N in our program,
we will put a parallelogram symbol there with a caption of "Input N" or "Read N" etc. Similarly, we will use this symbol to represent
output statements in program too. For Example, if we encounter an output statement in our program algorithm to show a message
"Enter a Number:", we will add a parallelogram symbol with the caption "Enter a Number". If we wish to show the value of a
variable, we may add parallelogram symbol with the text "The result =", result. Where "result" is a variable name.
• 3. Process
• Rectangle symbol is used to represent a process step. A process may be a calculation or assignment etc. The algorithmic statements
like Calculate Sum = Num1 + Num2 can be represented by the rectangle symbol in flowcharts. Similarly, the assignment statements
like Width = 10 may also be represented by rectangle symbol.
• 4. Selection
• Diamond symbol is used to represent a selection step. A condition is given in the diamond. If condition is true, then flow of control
will go in one direction. If condition is false, then control will go in other direction.
• 5. Flow Lines
• Arrow symbols are used to represent the direction of flow in the flowchart. There are four types of flow lines.
• 6. Connector
• Circle symbol is used to combine different flow lines. It is used as a connector symbol in flow charts.
Algorithmic Development: Flowcharting,
Decision Table (Contd)
• FlowChart (Contd):
• Example1: Develop a flowchart to input two numbers from
the user, calculate its sum and then display the result.
Algorithmic Development: Flowcharting,
Decision Table (Contd)
• FlowChart (Contd):
• Example2: Develop a flowchart to input 5 numbers
from the user, calculate its average and then display
the result.
Algorithmic Development: Structured
Programming Concepts
• Structured Programming
• It is a better way to program in a systematic and organized way. This
Programming Style improves the Quality, Clarity, Development Time of a
Software Development process. The Structured Programming involves THREE
Phases as,
• Top-Down Analysis
• Modular Programming
• Structured Code
Algorithmic Development: Structured
Programming Concepts (Contd)
• Structured Programming (Contd)
• Top-Down Analysis
• Programs are written to provide the solution to a problem. For larger problems, the solution
can be problematic. We might think where to start from? How to proceed? Where to
terminate?
• In this approach, subdivide the problem into smaller tasks (parts). So that the problem can be
analyzed, and an appropriate solution can be devised.
• Advantages
• Reduces the Problem-Solving Complexity
• It is not limited to a particular type of program
• How to DO?
• What is the Problem?
• What are the inputs?
• What is the Process?
• What is/are the Outputs?
Algorithmic Development: Structured
Programming Concepts (Contd)
• Structured Programming (Contd)
• Modular Programming
• Program is sub-divided into smaller Independent Modules.
• It is a solution to a Larger Program which is difficult to debug.
• Advantages
• Complex programs are divided into smaller manageable modules
• Multiple programmers can work simultaneously into different modules.
• It leads to re-usable code.
• Debugging (finding errors) is easy.
Algorithmic Development: Structured
Programming Concepts (Contd)
• Structured Programming (Contd)
• Structured Code
• Old Programs (Codes) are written using goto coding style.
• Structured code can be written by using control statements as, if, if-else, else if ladder, switch-case,
for loop, while loop, do while loop, etc.
• This aims to introduce a well-organized code using control transfer statements
• Advantages
• It improves the problem-solving process
• Well organized program
• Generalized programming methodology
• Clear description od data and structures
• Modifiable and documentable
Thanks
// My First C++ Program Hello World
// Created on 18 Jan 2022
// Course: 321EE3 Computer Programming
#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!" << endl;
return 0;
}

You might also like