Suppose we have data about students of a class i.e. name, addresses, date of birth, GPA and courses of study. This information is related to only a single entity i.e. student.
Which type of programming method you will use to initialize and display this information. Explain with a program.
The student information can be entered in a single entity called structure as given in below program. In the below program, a structure named as student has been created with the information as made structure elements.
using namespace std;
// Suppose we have data about students of a class i.e. name, addresses, date of birth, GPA and courses of study.
// This information is related to only a single entity i.e. student.
// Which type of programming method you will use to initialize and display this information. Explain with a program.
struct Student
{
string Name;
string Address;
int Day;
int Month;
int Year;
float gpa;
string course;
};
int main()
{
struct Student S1, S2, S3;
S1.Name = "abc";
S1.Address = "123, xyz";
S1.Day = 25;
S1.Month = 10;
S1.Year = 2001;
S1.gpa = 9.5;
S1.course ="English";
cout<<"\n\tName\t: "<<S1.Name;
cout<<"\n\tAddress\t: "<<S1.Address;
cout<<"\n\tDoB\t: "<<S1.Day<<"-"<<S1.Month<<"-"<<S1.Year;
cout<<"\n\tGPA\t: "<<S1.gpa;
cout<<"\n\tCourse\t: "<<S1.course;
return(0);
}
Comments
Leave a comment