Struct student name - Insurance Tips

A Hub of Best Guide Health Insurance Tips

Saturday, April 4, 2020

Struct student name

#include
#include
#include
using namespace std;

struct student
{
    char std1_name[100],std2_name[100];
    char std1_sub[100],std2_sub[100];
    int std1_age,std2_age;
    int std1_marks,std2_marks;
};
int main()
{
    cout<<"This Program takes information about two students and then displays information about the student with greater age.\n\n";
   
    student st1, st2;
    cout<<"Give information of about 1st student:"<    cout<<"Enter name: ";
    cin.getline(st1.std1_name, 100);
    cout<<"Enter age: ";
    cin>>st1.std1_age;
    cout<<"Enter subject: ";
    cin>>st1.std1_sub;
    cout<<"Enter marks: ";
    cin>>st1.std1_marks;
   
    cout<<"\n\nGive information of about 2nd student:"<    cin.ignore();
    cout<<"Enter name: ";
    cin.getline(st2.std2_name, 100);
    cout<<"Enter age: ";
    cin>>st2.std2_age;
    cout<<"Enter subject: ";
    cin>>st2.std2_sub;
    cout<<"Enter marks: ";
    cin>>st2.std2_marks;
    system("cls");
   
    if(st1.std1_age > st2.std2_age)
    {
     cout<<"Information about student with greater age is... "<     cout<<"Name: "<     cout<<"Age: "<     cout<<"Subject: "<     cout<<"Marks: "<     }
    else if(st1.std1_age < st2.std2_age)
    {
    cout<<"Information about student with greater age is..:"<    cout<<"name: "<    cout<<"Age: "<    cout<<"Subject: "<    cout<<"Marks: "<    }
    else
    {
        cout<<"Both the students have same age!";
    }
    getch();
}

No comments:

Post a Comment