Algorithms and Flowcharts
Algorithms and Flowcharts
Step 1: Start
Step 2: Read the value of 'N' from the user to check if it is a prime number.
Step 3: Declare and set count to 0 and i to 1.
Step 4: If i is less than or equal to N, (i<=N) go to Step 5; otherwise, go to Step 8.
Step 5: Check the condition N % i == 0. If true, go to Step 6; otherwise, go to Step 7.
Step 6: Increment count by 1(count=count+1).
Step 7: Increment i by 1(i=i+1) and go to Step 4.
Step 8: Check count. If count is equal to 2, (count==2) go to Step 9; otherwise, go to Step 10.
Step 9: Display "N is a prime number."
Step 10: Display "N is not a prime number."
Step 11: Stop.
Write an Algorithms for finding minimum and maximum numbers of a given set.
Step 1: Start
Step 2: Declare integer variables n, num, min, max, and i.
Step 3: Read the value of n from the user.
Step 4: Enter a loop from i = 1 to n (i=1; i<=n).
Step 5: Read an integer num from the user
Step 6: If i is equal to 1, set both min and max to num (min=max=num)
Step 7: If i is greater than 1: - If num is greater than max, update max to num (num>max).
If num is less than min, update min to num.
Step 8: Increment i by 1 to process the next number (i=i+1).
Step 9: After the loop:
a. Display "Maximum number is: max."
b. Display "Minimum number is: min."
Step 10: Stop.
Flow charts of
Draw a flowchart for finding if a number is prime number or Not.
Draw a flowchart for finding minimum and maximum numbers of a given set.
Draw a flowchart for finding roots of a quadratic equation.
Draw a flowchart for finding minimum and maximum numbers of a given set.
Start
Read ‘n’
Is No
i<=n
Yes
Read ‘num’
Yes
Read ‘num’
Stop
Is No
num>max
min=max=num
Yes
num<
min
max=num
Yes
min=num
I=i+1
Draw a flowchart for finding if a number is prime number or Not.
Start
Declare N,count=0,i=1
Read N
Is
i<=N
Yes
Count==2 No
Is
N%i==0
Yes N is not a prime number
Yes
i=i+1
Stop