1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
#include <string>
#include <iomanip>
using std::setprecision;
using std::fixed;
using namespace std;
struct StudentRecord
{
char Name[20];
int ID;
float GPA;
};
int main()
{
StudentRecord TESCStudent;
TESCStudent.Name[20] = 'S','u','p','e','r','P','r','o','g','r','a','m','m','e','r';
TESCStudent.ID = 1234;
TESCStudent.GPA = 4.0;
cout.precision(1);
cout<< "Name = " << TESCStudent.Name[20];
cout<< "\nID = " << TESCStudent.ID;
cout<< "\nGPA = " << fixed << showpoint << TESCStudent.GPA;
StudentRecord NewStudent;
cout<< "\nPlease Enter your name ";
cin>> NewStudent.Name;
cout<< "\nPlease Enter your ID ";
cin>> NewStudent.ID;
cout<< "\nPlease Enter your GPA ";
cin>> NewStudent.GPA;
cin.ignore();
cout<< "\nName = " << NewStudent.Name;
cout<< "\nID = " << NewStudent.ID;
cout<< "\nGPA = " << fixed << showpoint << NewStudent.GPA;
cin.ignore();
}
| |