(COMPLETE ANSWERS)
2025 - DUE 4 August 2025
For assistance contact
Email:
, //
=====================================================================
====
// Question 1: Dynamic Array for Exam Marks
// This program asks the user for the size of a dynamic array,
// populates it with exam marks, calculates the average, and then
// properly deallocates the memory.
//
=====================================================================
====
#include <iostream>
int main() {
int arraySize;
// Ask the user for the size of the dynamic array
std::cout << "Enter the number of students (array size): ";
std::cin >> arraySize;
// Validate the input to ensure a positive size
if (arraySize <= 0) {
std::cout << "Array size must be a positive number. Exiting program." << std::endl;
return 1;
}
// Create the dynamic array using 'new'
int* examMarks = new int[arraySize];
long long totalMarks = 0;