Algorithm
Algorithm is a step-by-step procedure, which defines a set of instructions to be executed ina certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.

  • Qualities of a good algorithm
    1. Input and output should be defined precisely.
    2. Each step in the algorithm should be clear and unambiguous.
    3. An Algorithm shouldn’t include computer code͘ Instead, the algorithm should be written in such a way that it can be used in different programming languages.

Written in such a way that it can be used in different programming languages. Good, logical programming is developed through good pre-code planning and organization. This is assisted by the use of pseudocode and program flowcharts.
Flowcharts
Flowcharts are written with program flow from the top of a page to the bottom. Each command is placed in a box of the appropriate shape, and arrows are used to direct program flow. The following shapes are often used in flowcharts:

cpp writing program Flowcharts

Pseudocode
Pseudocode is a method of describing computer algorithms using a combination of natural language and programming language. It is essentially an intermittent step towards the development of the actual code. It allows the programmer to formulate their thoughts on the organization and sequence of a computer algorithm without the need for actually following the exact coding syntax.

Examples –
Ques1. Write a flowchart and pseudocode for finding the sum of 2 numbers.

flowchart and pseudocode

Pseudocode
1. Start
2. Input 2 numbers ʹ number1 and number2
3. Add number1 and number2 to find the sum
4. Print sum
5. End

Ques2. Write a flowchart and pseudocode to find the area of a square.

flowchart and pseudocode to find the area

Pseudocode
1. Start
2. Input length of the square
3. Calculate area of square as length * length
4. Print area
5. End

Ques3. Write a flowchart and pseudocode to find simple interest.

flowchart and pseudocode to find simple interest

Pseudocode
1. Start
2. Input a principal as P, rate as R, and time as T
3. Calculate simple interest as P * R * T
4. Print simple interest
5. End

Ques4. Write a flowchart and pseudocode to convert temperature from
Fahrenheit (°F) to Celsius (°C).

flowchart and pseudocode to convert temperature

Pseudocode
1. Start
2. Read temperature in Fahrenheit
3. Calculate temperature with formula C=5/9*(F-32)
4. Print C
5. End

Ques5. Write a flowchart and pseudocode to check if a number is odd or even.

flowchart and pseudocode to check if a number is odd or even.

Pseudocode
1. Start
2. Input a number
3. If remainder, when a number is divided, is 0, print ͞Even number͟
4. Else print ͞Even number͟
5. End

Ques6. Write a flowchart and pseudocode to find the max of 3 numbers.

flowchart and pseudocode to find the max of 3 numbers

Pseudocode
1. Start
2. Read three numbers ʹ a,b and c
3. Compare a and b, if a > b
Compare a and c, if a > c
Print a
Else
Print c
Else
Compare b and c, if b > c
Print b
Else
Print c
4. End

Ques7. Write a flowchart and pseudocode to find the sum of n natural
numbers.

flowchart and pseudocode to find the sum of n natural numbers

Pseudocode
1. Start
2. Read a number n
3. Repeat the following till n becomes equal to 0
Add n in sum
Decrement n
4. Print sum
5. End

Ques8. Write a flowchart and pseudocode to find the factorial of a number.

flowchart and pseudocode to find the factorial of a number.

Pseudocode
1. Start
2. Read a number n
3. Initialise m =1
4. Repeat the following till m becomes equal to n
Multiply m with factorial
Increment m
5. Print factorial
6. End

Ques9. Write a flowchart and pseudocode to find if a number is prime or not.