Problem #10

Solution Source Code:

Code Overview

1. Header Files and Namespace:

  • <iostream> is included for input and output operations.
  • <string> is included for potential future use (not used in this program).
  • using namespace std; allows the use of standard functions without prefixing them with std::.

2. User Input Function (ReadNumbers)

  • Uses reference parameters (int &Mark1, int &Mark2, int &Mark3) to modify the values directly.
  • Prompts the user to enter three exam marks and stores them in the provided reference variables.

3. Sum Calculation Function (SumOf3Marks)

  • Takes three integer values as input.
  • Returns the sum of the three marks.

4. Average Calculation Function (CalculateAverage)

  • Calls SumOf3Marks() to compute the total sum.
  • Divides the sum by 3 to calculate the average.
  • Returns the computed average as a float.

5. Output Function (PrintResults)

  • Receives the calculated average as a parameter.
  • Prints "The average is: [Average]".

6. Program Execution (main())

  • Declares three integer variables (Mark1, Mark2, Mark3).
  • Calls ReadNumbers() to get user input.
  • Calls CalculateAverage() to compute the average.
  • Calls PrintResults() to display the average.
  • Returns 0 to indicate successful execution.

This structured explanation ensures clarity and ease of understanding.

Complete and Continue  
Discussion

0 comments