COS1512 Assignment
3 (COMPLETE
ANSWERS) 2025 - DUE
4 August 2025
FOR MORE ASSISTANCE CONTACT:
100% TRUSTED WORKINGS, EXPLANATIONS & SOLUTIONS
, COS1512 Assignment 3 (COMPLETE
ANSWERS) 2025 - DUE 4 August 2025
Question 1 Write a program that asks a user to enter the
size of a dynamic array that stores exam marks obtained
by students. Create the dynamic array and a loop that
allows the user to enter an exam mark into each array
element. Loop through the array, find the average mark
for the exam and output it. Delete the memory allocated
to your dynamic array before exiting your program.
Here's a simple C++ program that meets the requirements of your question:
✅ Program: Dynamic Array for Exam Marks and Average Calculation cpp Copy
Edit #include using namespace std;
int main() { int size; double sum = 0;
// Ask user to enter the number of students
cout << "Enter the number of students (size of array):
";
cin >> size;
// Dynamically allocate memory for the array
double* marks = new double[size];
// Get exam marks from the user
for (int i = 0; i < size; i++) {
cout << "Enter mark for student " << i + 1 << ": ";
cin >> marks[i];
sum += marks[i];
}
// Calculate average
double average = sum / size;
3 (COMPLETE
ANSWERS) 2025 - DUE
4 August 2025
FOR MORE ASSISTANCE CONTACT:
100% TRUSTED WORKINGS, EXPLANATIONS & SOLUTIONS
, COS1512 Assignment 3 (COMPLETE
ANSWERS) 2025 - DUE 4 August 2025
Question 1 Write a program that asks a user to enter the
size of a dynamic array that stores exam marks obtained
by students. Create the dynamic array and a loop that
allows the user to enter an exam mark into each array
element. Loop through the array, find the average mark
for the exam and output it. Delete the memory allocated
to your dynamic array before exiting your program.
Here's a simple C++ program that meets the requirements of your question:
✅ Program: Dynamic Array for Exam Marks and Average Calculation cpp Copy
Edit #include using namespace std;
int main() { int size; double sum = 0;
// Ask user to enter the number of students
cout << "Enter the number of students (size of array):
";
cin >> size;
// Dynamically allocate memory for the array
double* marks = new double[size];
// Get exam marks from the user
for (int i = 0; i < size; i++) {
cout << "Enter mark for student " << i + 1 << ": ";
cin >> marks[i];
sum += marks[i];
}
// Calculate average
double average = sum / size;