Array
Array
- Write a program that takes the number of grades from the user, prints
these grades, and then calculates the sum of the grades.
Answer
#include <iostream>
using namespace std;
int main() {
return 0;
}
1
- Write a function named sumArray that receives two parameters:
o an array of element type int
o an int that contains the number of elements of the array.
The function returns the sum of the elements of the array as an int.
After defining the function, write a program that takes the number of elements
from the user, allows the user to input these elements, and then calculates
and displays the sum of elements using SumArray function.
Answer
#include <iostream>
using namespace std;
int sum = 0;
return sum;
}
int main() {
int numElements;
cout << "Enter the number of elements in the array: ";
cin >> numElements;
int array[numElements];
return 0;
}