Draw a flowchart to find the sum of the square of first 15 odd numbers.

CS Professional · Information Technology and Systems Audit · PYQS · June 2017
Draw a flowchart to find the sum of the square of first 15 odd numbers.

Answer & Explanation:

A flowchart to find the sum of the square of the first 15 odd numbers would follow this logic: Start the process. Initialize variables: Set a variable 'Num' to 0 (to store the square of the current odd number), 'A' to 1 (to represent the current odd number, starting with the first odd number), and 'Sum' to 0 (to accumulate the sum of squares). Loop: Begin a loop that continues as long as 'A' (the current odd number) is less than or equal to 29 (since 29 is the 15th odd number: 2*15 - 1 = 29). Calculate Square: Inside the loop, calculate the square of 'A' and store it in 'Num' (i.e., Num = A * A). Accumulate Sum: Add 'Num' to 'Sum' (i.e., Sum = Sum + Num). Increment Odd Number: Increment 'A' by 2 to get the next odd number (i.e., A = A + 2). Check Condition: Check if 'A' has exceeded 29. If 'A' is still less than or equal to 29, continue the loop from step 4. Print Result: Once the loop terminates (when 'A' becomes greater than 29), print the final value of 'Sum'. End the process. Note: The provided solution includes an alternative flowchart with a different loop condition and increment logic (A=2A+1, A=15), which appears to have a logical inconsistency for generating sequential odd numbers and summing their squares correctly as per the problem statement. The description above is based on the first flowchart provided in the solution, which correctly identifies the 15th odd number as 29 and iterates accordingly.

Topics: Programming Concepts

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

Related Questions in this Topic