## Flowchart or Algorithm of Prime, Reverse, Largest Number

## Algorithm Prime

### Q) Draw the flowchart and write an algorithm to determine whether a number is prime or not.

- This is the algorithm to determine whether a number is prime or not.
- n-Accepted number
- i-loop variable

Image Source ~ Crafted With Â©Ishwaranand – 2020 ~ Image by Â©Ishwaranand |

step 1: start

step 2: [Accept a number] read n

step 3: set i = 2

step 4: Repeat steps 5and 6 until i < n

step 5: [ check whether n is divisible or not]

Â Â Â Â Â Â Â if n % i == 0 then

Â Â Â Â Â Â Â Â Â Goto step7

Â Â Â Â Â Â Else

Â Â Â Â Â Â Â Â Â Goto step6

step 6:Â set i = i + 1

step 7:Â if i == n then

Â Â Â Â Â Â Â Â Print “number is prime”

Â Â Â Â Â Else

Â Â Â Â Â Â Â Print “number is not prime”

step 8: stop

## Algorithm Reverse

### Q) Draw the flowchart and write an algorithm to find the reverse of a given number.

- This is the algorithm to print the reverse of an accepted number
- n- Accepted number
- r- variable for remainder
- rev- the reverse of a number

Image Source ~ Crafted With Â©Ishwaranand – 2020 ~ Image by Â©Ishwaranand |

step 1: start

step 2: read n

step 3: Set rev=0

step 4: repeat steps 5,6 & 7 unit n!=0

step 5: set r = n % 10

step 6: set rev = rev*10 + r

step 7: set n=n/10

step 8: print rev

step 9: stop

## Algorithm largest

### Q) Draw the flowchart and write an algorithm to find the largest of a given number.

- This is the algorithm to find largest of three numbers a,b,c – Accepted numbers

Image Source ~ Crafted With Â©Ishwaranand – 2020 ~ Image by Â©Ishwaranand |

step 1Â Start

step 2Â [Accepted three number]

Â Â Â Â read a,b,c,

step 3 if a > b then

Â Â Â Â Â Â if a > c then

Â Â Â Â Â Â Â Â Print a is the largest

Â Â Â Â Â Â Else

Â Â Â Â Â Â Â Â Print c is the largest

Â Â Â Â Else

Â Â Â Â Â if b > c then

Â Â Â Â Â Â Print b is the largest

Â Â Â Â Â Else

Â Â Â Â Â Â Print c is the largest

step 4: stop

Last updated on Wednesday - May 24th, 2023