Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I'm having problem with this question c++ ok so our professor is asking us this question and I'm confuse haha and yes I'm going

Hi I'm having problem with this question c++ ok so our professor is asking us this question and I'm confuse haha and yes I'm going to rate you up thank you!

/Build on lab #7 - Two-dimensional arrays

Extend your lab #7 solution to use dynamic arrays (of any size) with dynamic memory allocation.

The user first enters the number of tests and

number of students (check: both of these numbers should be >0).

Then the two-dimensional array is created with the "new" keyword (dynamic memory allocation).

The rest is the same functionality you implemented for Lab #7:

//Ask the user to input the test scores of all students for all tests.

//Then for each student compute the average test score,

//as well as the student's highest and lowest test score

//and print them out.

In the end, remember to delete the memory used!!

_____

Update: You have to initialize the dynamic 2d array after the number of students and number of tests are read in with:

int **ary = new int*[students]; for(int i = 0; i < students; ++i) { ary[i] = new int[tests]; }

and then clean up would be:

for(int i = 0; i < students; ++i) { delete [] ary[i]; } delete [] ary; 

This is my lab #7 answer tho and question

//Q1 Two-dimensional arrays

//Ask the user to input the test scores of 5 students for 3 tests.

//Then for each student compute the average test score,

//as well as the student's highest and lowest test score

//and print them out.

#include

using namespace std;

int main(){

float test1,test2,test3;

float min,max,sum;

for(int i=0;i<5;i++){

min = 100;

sum=0;

max=-1;

cout<<"Student "<

cout<<"Enter test1 marks : ";

cin>>test1;

if(test1>max)max=test1;

if(test1

sum+=test1;

cout<<"Enter test2 marks : ";

cin>>test2;

if(test2>max)max=test2;

if(test2

sum+=test2;

cout<<"Enter test3 marks : ";

cin>>test3;

if(test3>max)max=test3;

if(test3

sum+=test3;

cout<<"Minimum marks for student "<

cout<<"Maximum marks for student "<

cout<<"Average marks for student "<

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions