Answer to Question #225475 in C++ for Ali

Question #225475
Develop C++ code for a function that takes the GPA of students from the user. This function should works for different class size specified by the user. Function should display the GPA of those students who had GPA more than 3.5.
1
Expert's answer
2021-08-12T06:17:53-0400
#include<iostream>
using namespace std;
void GPACompute(int n){
	float arr[n];
	cout<<"Enter the GPA of  "<<n<<"  students\n";
	for(int i=0; i<n; i++){
		cout<<"GPA for student "<<(i+1)<<endl;
		cin>>arr[i];
	}
	cout<<"GPA of students who have more than 3.5 are: \n";
	for(int i=0; i<n; i++){
		if(arr[i]>3.5){
			cout<<arr[i]<<endl;
		}
	}
}
//Driver code
int main(){
	int n;
	cout<<"Enter the class size \n";
	cin>>n;
	GPACompute(n);
}

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