, COS1512 Assignment 3 (COMPLETE ANSWERS)
Semester 2 2025 - DUE 4 August 2025; 100%
TRUSTED Complete, trusted solutions and
explanations.
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.
✅C++ Program: Average of Exam Marks using Dynamic Array
#include <iostream>
using namespace std;
int main() {
int size;
cout << "Enter the number of students: ";
cin >> size;
// Dynamically allocate memory for the array
float* marks = new float[size];
// Input marks
for (int i = 0; i < size; ++i) {
cout << "Enter mark for student " << i +
1 << ": ";
cin >> marks[i];
Semester 2 2025 - DUE 4 August 2025; 100%
TRUSTED Complete, trusted solutions and
explanations.
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.
✅C++ Program: Average of Exam Marks using Dynamic Array
#include <iostream>
using namespace std;
int main() {
int size;
cout << "Enter the number of students: ";
cin >> size;
// Dynamically allocate memory for the array
float* marks = new float[size];
// Input marks
for (int i = 0; i < size; ++i) {
cout << "Enter mark for student " << i +
1 << ": ";
cin >> marks[i];