You are on page 1of 9

Lab 1

CS100 - Computational Problem Solving


Fall 2020
Problem Solving Process
Steps:
1. Problem Identification
2. Discovering a method of the solution
 writing an algorithm
 flow chart
3. Producing a computer program
 translating the algorithm into a programming language (C, C++, python, Java
etc)
2. Discovering a method of the solution
• Writing algorithm - a sequence of precise instructions which
leads to a solution.

Problem Solution

Can you think about


Efficient approach writing an algorithm to
make a cup of tea?
2. Discovering a method of the solution
• Flow Chart - a pictorial representation of an algorithm, workflow or process

• Gives better understanding through visualization

Flow line

Decision
Terminal
(start/end)

Process Input/Output

Components of a flow chart


3. Producing a computer program

• A computer program is a list of instructions that tells a computer


what to do.
• Everything a computer does is the result of an instruction.
• A computer program is written in a programming language.
3. Producing a computer program

#include <iostream>
using namespace std;

int main()
{
cout << “Hello world”;
return 0;
}
3. Producing a computer program
• Translation of a program into binary is important
• A computer understands only the language of 1s and 0s
Example: Computing sum of 3 numbers
1. Acquire 1st number
2. Store the number in variable x
3. Acquire 2nd number
4. Store the number in variable y
5. Add x and y
6. Store the result in variable sum1
7. Acquire 3rd number
8. Store the number in variable z
9. Add sum1 and z This is not an efficient
algorithm, though.
10. Store the result of addition in variable sum2 Can you write a better
11. Show the sum2 as result one?

You might also like