plz help write a program in C language using arrays for booking ticketsof bus (5
ID: 3615631 • Letter: P
Question
plz help write a program in C language using arrays for booking ticketsof bus (5 seats)the program should be like this press 1 to show number of seats available. press the desired seat number to book it e.g if u want to book seat number 2 press 2. the program should run untill all seats are filled, i.e when all seats are booked, it should display all seats are booked write a program in C language using arrays for booking ticketsof bus (5 seats)
the program should be like this press 1 to show number of seats available. press the desired seat number to book it e.g if u want to book seat number 2 press 2. the program should run untill all seats are filled, i.e when all seats are booked, it should display all seats are booked
Explanation / Answer
#include<conio.h>main() { int seats[5]={0,0,0,0,0}; int count=0, num=0;
do{ cout<<"Enter 1 for checking vacantseats"<<endl; cout<<"Enter 2 for seat selction"; cin>>num; if(num==1) { for(int v=0;v<5;v++) { if(seats[v]!=0) cout<<"Seat No. "<<v+1<<" is Vacant"; } } int sel=0; if(num==2) { cout<<"Enter Seat No. to select it"; cin>>sel; if(seat[sel]==0) seat[sel]=1; count++; } }while(count<5);
getch(); }
Hope you found it helpful... Please Rate
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.