Draw a flowchart to find the sum of first 50 odd natural numbers.

CS Professional · Information Technology and Systems Audit · PYQS · December 2015
Draw a flowchart to find the sum of first 50 odd natural numbers.

Answer & Explanation:

A flowchart to find the sum of the first 50 odd natural numbers can be described as follows: Alternative 1: START Initialize a variable N to 1 (the first odd number). Initialize a variable SUM to 0. Loop: Add the current value of N to SUM ( SUM = SUM + N ). Increment N by 2 to get the next odd number ( N = N + 2 ). Decision: Check if N is less than or equal to 99 (since the 50th odd number is 99). If N <= 99 (Yes), go back to step 4 (Loop). If N > 99 (No), proceed to step 8. PRINT SUM (The final sum of the first 50 odd numbers). END Alternative 2 (using a counter for 50 iterations): START Initialize a variable i to 1 (representing the current odd number). Initialize a variable Sum to 0. Loop: Add the current value of i to Sum ( SUM = SUM + i ). Increment i by 2 to get the next odd number ( i = i + 2 ). Decision: Check if i is less than or equal to 100 (to ensure 50 odd numbers are processed, from 1 up to 99). If i <= 100 (Yes), go back to step 4 (Loop). If i > 100 (No), proceed to step 8. PRINT SUM (The final sum of the first 50 odd numbers). STOP

Topics: Programming & Logic

Open in Interactive Practice Hub · Full Practice Hub · Chapter Weightage · More in this subject

Related Questions in this Topic