Write a C++ program that uses 2 functions the first is to read an array of students’ grades and return the sum of the all grades to the main program. And the second function will receive the sum of all grades from the main program and calculate and print the average of the students’ grade.

Sure! Here's a step-by-step guide to write a C++ program that uses two functions to calculate the sum of student grades and their average:

Step 1: Include the necessary header files.
```cpp
#include <iostream>
using namespace std;
```

Step 2: Define the two functions to calculate the sum and average.

```cpp
// Function to calculate the sum of grades
int calculateSum(int grades[], int size) {
int sum = 0;
for (int i = 0; i < size; i++) {
sum += grades[i];
}
return sum;
}

// Function to calculate the average of grades
double calculateAverage(int sum, int size) {
return static_cast<double>(sum) / size;
}
```

Step 3: Write the main program to read the grades and call the functions.

```cpp
int main() {
int numGrades;
cout << "Enter the number of students: ";
cin >> numGrades;

int grades[numGrades];

cout << "Enter the grades one by one:\n";
for (int i = 0; i < numGrades; i++) {
cin >> grades[i];
}

int totalSum = calculateSum(grades, numGrades);
double average = calculateAverage(totalSum, numGrades);

cout << "Sum of grades: " << totalSum << endl;
cout << "Average grade: " << average << endl;

return 0;
}
```

Step 4: Compile and run the program.

This code will prompt the user to enter the number of students, followed by the individual grades of each student. It will then calculate the sum of all the grades using the `calculateSum` function and the average using the `calculateAverage` function. Finally, it will print the sum and average.

I hope this helps! Let me know if you have any further questions.

To write a C++ program that uses two functions to read an array of students' grades and calculate the average, you can follow these steps:

1. Declare an array to store the students' grades.
2. Write a function to read the grades from the user and calculate the sum of all grades.
3. Write another function to calculate and print the average grade using the sum obtained from the first function.
4. Call these functions from the main program.

Here's the code for the program:

```c++
#include<iostream>
using namespace std;

// Function to read the grades and calculate the sum
float calculateSum(float grades[], int size) {
float sum = 0;
for (int i = 0; i < size; i++) {
cout << "Enter grade for student " << i + 1 << ": ";
cin >> grades[i];
sum += grades[i];
}
return sum;
}

// Function to calculate and print the average grade
void calculateAverage(float sum, int size) {
float average = sum / size;
cout << "Average grade: " << average << endl;
}

int main() {
int size;
cout << "Enter the number of students: ";
cin >> size;

float grades[size];
float sum = calculateSum(grades, size);
calculateAverage(sum, size);

return 0;
}
```

Explanation:

1. The program starts by taking input from the user for the number of students.
2. An array `grades[]` of size `size` is declared to store the grades.
3. The `calculateSum()` function is defined to read the grades from the user and calculate the sum of all grades. It takes the `grades` array and `size` as parameters.
4. Inside the `calculateSum()` function, a `for` loop is used to iterate through the array and prompt the user to enter the grade for each student. The sum is updated with each grade entry.
5. The `calculateSum()` function returns the sum.
6. The `calculateAverage()` function is defined to calculate and print the average grade. It takes the `sum` and `size` as parameters.
7. Inside the `calculateAverage()` function, the average is calculated by dividing the sum by the number of students.
8. The average grade is printed to the console.
9. In the `main()` function, the user is prompted to enter the number of students.
10. An array `grades[]` of size `size` is declared to store the grades.
11. The `calculateSum()` function is called, passing the `grades` array and `size` as arguments. The returned sum is stored in the `sum` variable.
12. The `calculateAverage()` function is called, passing the `sum` and `size` as arguments.
13. The program ends by returning 0 from the `main()` function.