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
#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;
}
Comments
Leave a comment