Answer to Question #234143 in C++ for nawab ul haq

Question #234143

Write a Program in C++ to enter the record of 100 Students using structure pointer as a function parameter.

Fields for structures are: “std_name”, “std_id”, “std_roll_no”, “std__gpa” & “std_award”;

apply a check such that those students having gpa greater or equal to 3.5 so that these students will get Rs. 10,000/- per semester as a scholarship amount


1
Expert's answer
2021-09-07T04:26:57-0400
#include <iostream>
using namespace std;
 
#define MAX 10
 
class student
{
    private:
        char  std_name[30];
        int   std_roll_no;
        int std_id;
        int   std__gpa;
        float std_award;
    public:
        void getDetails(void);
        void displayDetails(void);
};
void student::getDetails(void){
    cout << "Enter name: " ;
    cin >>std_name;
    cout << "Enter student id: ";
    cin >> std_id;
    cout << "Enter roll number: ";
    cin >> std_roll_no;
    cout << "Enter the student gpa: ";
    cin >> std__gpa;
}
void student::displayDetails(void){
    cout << "Student details:\n";
    cout << "Name:"<<std_name <<",Id:"<<std_id<< ",Roll Number:" << std_roll_no << ",Student gpa:" << std__gpa ;
     if(std__gpa>=3.5){
    	cout<<" The student qualifies for the scholarship amounting to Rs. 10,000/- per semester\n "<<endl;}
	 else{
	 	cout<<" The student does not qualify for the scholarship.\n ";
	 }
}
 
int main()
{
    student std[MAX];
    int x,loop;
     
    cout << "Enter total number of students: ";
    cin >> x;
     
    for(loop=0;loop< x; loop++){
        cout << "Enter details of student " << loop+1 << ":\n";
        std[loop].getDetails();
    }
     
    cout << endl;
     
    for(loop=0;loop< x; loop++){
        cout << "Details of student " << (loop+1) << ":\n";
        std[loop].displayDetails();
    }
     
    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