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) 2025 - DUE 4 August 2025; 100% TRUSTED Complete, trusted solutions and explanations Ensure your success with us..

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

COS1512 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 4 August 2025; 100% TRUSTED Complete, trusted solutions and explanations Ensure your success with us..

Institution
Course









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

Connected book

Written for

Institution
Course

Document information

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

Subjects

Content preview

COS1512 Assignment
3 (COMPLETE
ANSWERS) 2025 - DUE
4 August 2025
NO PLAGIARISM
[Pick the date]
[Type the company name]


, Exam (elaborations)
COS1512 Assignment 3 (COMPLETE
ANSWERS) 2025 - DUE 4 August 2025
 Course
 Introduction to Programming II (COS1512)
 Institution
 University Of South Africa (Unisa)
 Book
 Introduction to Programming

COS1512 Assignment 3 (COMPLETE ANSWERS) 2025 - DUE 4 August 2025;
100% TRUSTED Complete, trusted solutions and explanations Ensure your
success with us..



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.
#include <iostream>
#include <new> // Required for std::bad_alloc
#include <iomanip> // Required for formatting the output

int main() {
// --- Step 1: Ask the user for the size of the dynamic array ---
int arraySize;
std::cout << "Enter the number of students (size of the array): ";
std::cin >> arraySize;

// Validate that the size is a positive number
if (arraySize <= 0) {
std::cerr << "Error: The array size must be a positive number."
<< std::endl;
return 1; // Exit with an error code
}

// --- Step 2: Create the dynamic array and handle memory allocation
errors ---
// We use a try-catch block to handle the case where memory cannot be
allocated.

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.
ivymwendwa47820 University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
357
Member since
1 year
Number of followers
156
Documents
883
Last sold
1 month ago

3.6

71 reviews

5
29
4
13
3
13
2
5
1
11

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 notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

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

Student with book image

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

Alisha Student

Frequently asked questions