Algorithm and Flowchart

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

01.

Find the sum of two numbers


Algorithm :

Step : 1 : Start the program

Step : 2 : Get the input values A and B

Step : 3 : sum C =A+B

Step : 4 : Print the output of C

Step : 5 : Display the result of C

Step : 6 : Stop the program

Flow chart :

START

READ A,B

SUM = A+B

PRINT SUM

STOP
02. Find greatest of two numbers
Algorithm :

Step : 1 : Start the program

Step : 2 : Get the values for A, B

Step : 3 : Find the greatest of two

(i) Check the condition (A>B) then display A is greater


(ii) Else display B is greater

Step : 4 : Store the greatest number of the two

Step : 5 : Display the greatest line of the two

Step : 6 : Stop the program

Flowchart :

START

READ A,B

IF A>B
YES

DISPLAY A IS GREATER
NO

DISPLAY B IS GREATER

STOP
03. To check whether the given number is even or odd
Algorithm :

Step : 1 : Start the program

Step : 2 : Get the value of A

Step : 3 : Process A % 2

Step : 4 : Display A is even if A%2 is true , else A is odd

Step : 5 : Stop the program

Flowchart :

START

GET A

NO IF A%2 YES

(==0)

A IS ODD A IS EVEN

STOP
04. To check whether the given year is a leap year
Algorithm :

Step : 1 : Start the program

Step : 2 : Get the value of A

Step : 3 : Process the data a%4

Step : 4 : Display a is a leap year if a%4 is true , else A is not a leap year

Step : 5 : Stop the program

Flowchart :

START

GET A

YES IF A%4(==0) NO

A IS A LEAP YEAR A IS NOT A LEAP YEAR

STOP
05. To check the greatest of three numbers
Algorithm :

Step : 1 : Start the program

Step : 2 : Get the values for A , B , C

Step : 3 : Find the greatest of the three

(i) Check the condition (A>B) and (A>C) if yes display A is greater
(ii) Check the condition (B>A) and (B>C) if yes display B is greater
(iii) Else display C is greater

Step : 4 : Store the greatest of the three numbers

Step : 5 : Display the greatest of value out of the three numbers

Step : 6 : Stop the program

Flowchart : START

READ A,B,C

NO IF(A>B) & (A>C) YES

DISPLAY A IS >

IF (B>A) & (B>C) YES

DISPLAY B IS >
NO

DISPLAY C IS >

STOP

You might also like