
Struct EL
By: a guest on
Jun 4th, 2012 | syntax:
C++ | size: 0.58 KB | hits: 14 | expires: Never
#include<iostream>
#include<string>
using namespace std;
struct student
{
int idno;
string name[20];
float gpa;
char grade[2];
}
s[5];
int main()
{
for(int i=0;i<5;i++)
{
cout<<"Enter idno for the student: ";
cin>>s[i].idno;
cout<<"Enter the name of the student: ";
cin>>s[i].name;
cout<<"Enter GPA: ";
cin>>s[i].gpa;
cout<<"Enter the letter grade: ";
cin>>s[i].grade;
}
cout<<"\nIDNO"<<"\t"<<"NAME"<<"\t\t"<<"GPA"<<"\t"<<"GRADE"<<endl;
for(int i=0;i<5; i++)
cout<<s[i].idno<<"\t"<<s[i].name<<"\t\t"<<s[i].gpa<<"\t"<<s[i].grade<<endl;
}