Actually there is a party thrown by a millionaire,i am trying to store their names and ages using a structure array of 2 guests, then at the end i am trying to display total number of guests and divide them by their age group. help me guys!this is my first time posting!spare my mistakes please!thank you!
#include "iostream"
#include "string"
using namespace std;
struct guests
{
    string name;
    int age;
};
int main()
{
    int i=0,j=0;
    guests guest[1];
    try
    {
        do{
            cout<<"enter your name"<<endl;
            getline(cin,guest[i].name).get();
            cout<<"enter your age"<<endl;
            cin>>guest[i].age;
            cin.get();
            i++;
        }
        while(i>0 && i<2);
        cout<<i<<"number of guests attended the party"<<endl;
        for(i=0;i<2;i++)
        {
            if((guest[i].age>19 && guest[i].age<31))
            {
                j++;
                cout<<j<<"number of guests of age group between 20 and 30 are her"<<endl;
            }
            else if((guest[i].age>29 && guest[i].age<41))
            {
                j=0;
                j++;
                cout<<j<<"number of guests of age group between 30 and 40 are here"<<endl;
            }
            else
                cout<<j<<"number of guests of agegroup between 40 and 50 are here"<<endl;
        }
    }
    catch (int e)
    {
        cout << "An exception occurred. Exception Nr. " << e << endl;
    }
    return 0;
    cin.get();
}
 
     
     
     
    