The document provides examples of algorithms and flowcharts for three tasks: 1) Generating the sum of the first N natural numbers. 2) Determining whether a given number is odd or even. 3) Determining the largest of three given numbers. Each example includes the step-by-step algorithm and describes how it solves the problem.
The document provides examples of algorithms and flowcharts for three tasks: 1) Generating the sum of the first N natural numbers. 2) Determining whether a given number is odd or even. 3) Determining the largest of three given numbers. Each example includes the step-by-step algorithm and describes how it solves the problem.
The document provides examples of algorithms and flowcharts for three tasks: 1) Generating the sum of the first N natural numbers. 2) Determining whether a given number is odd or even. 3) Determining the largest of three given numbers. Each example includes the step-by-step algorithm and describes how it solves the problem.
1. An algorithm and flowchart to generate sum of first N natural numbers.
Solution Algorithm Step 1: Start Step 2: Read an integer value i.e. N Step 3: Assign, i=1. Step 4: Calculate, Sum= Sum+ i. Increase i by 1. Step 5: If i<=N then go to Step 4. Else go to step 6. Step 6: Display Sum. Step 7: End. 2. An algorithm and a flowchart to determine whether a given number is odd or even. Solution Algorithm Step 1: Start Step 2: Read a number "n". Step 3: Calculate, the remainder of n divided by 2 (i.e. n/2) that is rem=%2. Step 4: If the rem=0 then Display "n" is even number and go to end. Else go to Step 5. Step 5: Display "n" is odd. Step 6: End. 3. Algorithm and flowchart to determine the largest of three given numbers. Solution Algorithm Step 1: Start. Step 2: Read three numbers and store them as x, y, z. Step 3: Compare x and y. If x is greater than y then go to step 6 else go to step 4. Step 4: Compare y and z. If y is greater than z then print "y is largest" and go to step 8 otherwise go to step 5. Step 5: Print "z is largest" and go to step 8. Step 6: Compare x and z. If x is greater than z then print "x is largest" and go to step 7. Step 7: Print "z is largest" and go to step 8. Step 8: End