Answer to Question #241059 in C++ for vishal

Question #241059

Write a program to read the GPA of students from users and display the details using dynamic memory allocation.


Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

Include the following member function in the Main class

Member FunctionDescriptionvoid display(float arr[], int size)This method is used to display the student's GPA details.

 

In the main method, obtain input from the user in the console and call the display method to display the GPA details.

Note:

Use a new keyword to create a dynamic array to store the GPA details.

OUTPUT

Enter total number of students:

2

Enter GPA of students

7.8

6.7

Students GPA Details

Student1 : 7.8

Student2 : 6.7


1
Expert's answer
2021-09-23T17:46:44-0400
#include <iostream>


using namespace std;


void display(float arr[], int size){
    cout<<"\nStudents GPA Details\n";
    for(int i=0;i<size;i++){
        cout<<"\nStudent"<<(i+1)<<":"<<arr[i];
    }
}
int main()
{
    cout<<"\nEnter total number of students:";
    int n;
    cin>>n;
    float *GPA = new float[n];
    cout<<"\nEnter GPA of students: \n";
    for(int i=0;i<n;i++){
        cin>>GPA[i];
    }
    display(GPA,n);
    delete [] GPA;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS