Don't like ads? PRO users don't see any ads ;-)
Guest

Struct EL

By: a guest on Jun 4th, 2012  |  syntax: C++  |  size: 0.58 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. struct student
  6. {
  7.         int idno;
  8.         string name[20];
  9.         float gpa;
  10.         char grade[2];
  11. }
  12.  
  13. s[5];
  14.  
  15. int main()
  16. {
  17.  
  18.         for(int i=0;i<5;i++)
  19.         {
  20.         cout<<"Enter idno for the student: ";
  21.         cin>>s[i].idno;
  22.         cout<<"Enter the name of the student: ";
  23.         cin>>s[i].name;
  24.         cout<<"Enter GPA: ";
  25.         cin>>s[i].gpa;
  26.         cout<<"Enter the letter grade: ";
  27.         cin>>s[i].grade;
  28.         }
  29.         cout<<"\nIDNO"<<"\t"<<"NAME"<<"\t\t"<<"GPA"<<"\t"<<"GRADE"<<endl;
  30.  
  31.         for(int i=0;i<5; i++)
  32.                 cout<<s[i].idno<<"\t"<<s[i].name<<"\t\t"<<s[i].gpa<<"\t"<<s[i].grade<<endl;
  33. }