Code:
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
void message(void);
int main()
{
const int limit=10;
int c,i,a[limit];
int num;
static int seat1=0;
static int seat2=0;
static int booking1,booking2;
while(seat1<5&&seat2<10)
{
message();
cin>>num;
for(i=0,c=0,c<5;i<5;i++,c++)
{
a[i]=0;
a[c]=0;
} //end for
if(num==1)
{
a[i]=1;
seat1+=a[i];
booking1=seat1;
cout<<" You bought seat "<<seat1<<" in first class"<<endl;
} //end if
if(num==2)
{
a[c]=1;
seat2+=a[c];
booking2=seat2;
cout<<"You bought seat "<<seat2<<" in eco class"<<endl;
} //end if
if(num==0)
{
cout<<"Exiting.."<<endl;
cout<<"The seats in first class are: "<<booking1<<endl;
cout<<"The seats in economical class are: "<<booking2<<endl;
system("pause");
return 0;
} //end if
} //end while
system("pause");
return 0;
}
void message(void)
{
cout<<"Choose an option: 1 for first class, 2 for economical class or 0 to quit"<<endl;
}