In: Computer Science
Reserve the memory for 2 students at compile time and make a menu which should allow user to add the student data one by one.
use c++ .
Dear Student,
below i have written the complete C++ program as per the requirement.
==============================================================
Program:
==============================================================
#include<iostream>
using namespace std;
//Student structure Declaration
struct Student
{
string name;
int EnrNum;
double CGPA;
string DegreeProg;
};
//start of the main function
int main()
{
Student s[2];
for(int i = 0; i<2; i++)
{
cout<<"\nEnter student "<<(i+1)<<" Name: ";
cin.ignore();
getline(cin, s[i].name);
cout<<"Enter student "<<(i+1)<<" Enrollment
Number: ";
cin>>s[i].EnrNum;
cout<<"Enter student "<<(i+1)<<" CGPA: ";
cin>>s[i].CGPA;
cout<<"Enter student "<<(i+1)<<" Degree Program:
";
cin.ignore();
getline(cin,s[i].DegreeProg);
cin.clear();
}
//Print the student information
for(int i = 0; i<2; i++)
{
cout<<"Student "<<(i+1)<<" Name is:
"<<s[i].name<<endl;
cout<<"Student "<<(i+1)<<" Enrollment Number is:
"<<s[i].EnrNum<<endl;
cout<<"Student "<<(i+1)<<" CGPA is :
"<<s[i].CGPA<<endl;
cout<<"Student "<<(i+1)<<" Degree Program is:
"<<s[i].DegreeProg<<endl;
cout<<endl;
}
return 0;
}
=============================================================
Sample Output:
=============================================================
Kindly Check and Verify Thanks..!!!