100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COS1512 Assignment 3 |COMPLETE ANSWERS| Semester 2 2025 - DUE 4 August 2025

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
04-08-2025
Written in
2025/2026

COS1512 Assignment 3 |COMPLETE ANSWERS| Semester 2 2025 - DUE 4 August 2025; 100% TRUSTED Complete, trusted solutions and explanations.

Institution
Module









Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Module

Document information

Uploaded on
August 4, 2025
Number of pages
7
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

, COS1512 Assignment 3
Semester 2 2025
DUE 4 August 2025
Use this document as a guide and for references to answer your assignment

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.

✅Program Objective

 Ask the user to enter the size of a dynamic array for exam marks.
 Use a loop to populate the array.
 Calculate and output the average mark.
 Free the dynamically allocated memory before exiting.



�C++ Program:

#include <iostream>
using namespace std;

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

// Allocate memory dynamically
float* marks = new float[size];

// Input exam marks
for (int i = 0; i < size; ++i) {
cout << "Enter mark for student " << i + 1 << ": ";
cin >> marks[i];
}

// Calculate average

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
SparkHubIdeas university of south africa (unisa)
Follow You need to be logged in order to follow users or courses
Sold
45
Member since
4 months
Number of followers
0
Documents
201
Last sold
2 weeks ago

4.0

5 reviews

5
2
4
1
3
2
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions