19 - Draw Flowchart and Write an Algorithm For Find Out Whether The Given Number Is Prime Or Not

Draw Flowchart and Write an Algorithm For Find Out Whether The Given Number Is Prime Or Not.



Algorithm:

Step 1: Start
Step 2: Declare num, i = 2, factors = 2.
Step 3: Enter the num.
Step 4: If (i < num) then goto step 5 else goto step 8.
Step 5: If (num % i == 0) then goto step 6 else goto step 7.
Step 6: factors = factors + 1;
Step 7: i = i + 1, goto step 4.
Step 8: If (factors == 2) then goto step 9 else goto step 10.
Step 9: Display num is Prime number.
Step 10: Display num is Not Prime number.
Step 11: Stop.


Flowchart:




Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.