struct student
{
unsigned short studNum;
string name;
string course;
string yearLevel;
string section;
}
#include<iostream>
using namespace std;
struct student
{
unsigned short studNum;
string name;
string course;
string yearLevel;
string section;
};
int main(){
int n;
cout<<"Enter the number of students to enter their details:\n";
cin>>n;
cout<<"Enter the details of "<<n<<" students\n";
struct student stu[n];
for(int i=0; i<n; i++){
cout<<"Student "<<(i+1)<<":"<<endl;
cout<<"Enter student number:\n";
cin>>stu[i].studNum;
cout<<"Enter the student name:\n";
cin>>stu[i].name;
cout<<"Enter the student course:\n";
cin>>stu[i].course;
cout<<"Enter the student year:\n";
cin>>stu[i].yearLevel;
cout<<"Enter the student section:\n";
cin>>stu[i].section;
}
cout<<"The students' details are:\n";
for(int i=0; i<n; i++){
cout<<"Student "<<(i+1)<<":"<<endl;
cout<<"Number: "<<stu[i].studNum<<endl;
cout<<"Name: "<<stu[i].name<<endl;
cout<<"Course: "<<stu[i].course<<endl;
cout<<"Year Level: "<<stu[i].yearLevel<<endl;
cout<<"Section: "<<stu[i].section<<endl;
}
}
Comments
Leave a comment