#include <stdio.h>
int main(void)
int movieChoice;
int seatNum;
int seatPlan[5][10] = { 0 };
int rows, cols;
char space;
void seatDisplay(int a[][10]);
void seatNew(int n[][10]);
void seatDisplay(int a[][10]) { //this function shows the seat plan
for (int i = 0; i<5; i++) {
for (int j = 0; j<10; j++) {
cout << a[i][j];
printf(" \n");
}
}
}
void seatNew(int n[][10]) { // this function shows the reserved seats
for (int i = 0; i<5; i++) {
for (int j = 0; j<10; j++) {
cout << n[i][j];
printf(" \n");
}
}
}
void seatRes(int x) { //this function reserves the seats
while (x>50 || x <= 0) {
printf("Cannot process Reservation. ");
printf("Please Enter number of seats to be reserved: ");
scanf("%d", &seatNum);
}
printf("Please enter seat row and column you wish to reserve: \n");
for (int i = 1; i <= x; i++) {
printf("(row,column): ");
scanf("%d %d %d", &rows, &space, &cols);
seatPlan[rows][cols] = 1;
}
}
int priceComp(int y) { //this function computes and displays the ticket price
int price;
price = y * 150;
printf("You have reserved " y " seat(s).");
printf("Ticket Price: ");
return 0;
}
int main() { //this is the main function
printf("Welcome to Movie World \n" );
printf("1 - Movie 1 \n");
printf("2 - Movie 2 \n");
printf("3 - Movie 3 \n");
printf("Enter your choice of Movie: ");
scanf("%d", &movieChoice);
switch (movieChoice) {
case 1 :
printf("Movie 1 \n");
printf("Seating Reservation \n");
seatDisplay(seatPlan);
printf("How many seats would you like to reserve?: ");
scanf("%d", &seatNum);
seatRes(seatNum);
printf("Seating Reservation \n");
printf("1 marks your reserved seat \n");
printf("------Movie 1 SEAT PLAN----------- \n");
seatNew(seatPlan);
priceComp(seatNum);
break;
case 2 :
printf("Movie 2 \n" );
printf("Seating Reservation \n");
seatDisplay(seatPlan);
printf("How many seats would you like to reserve?: ");
scanf("%d", &seatNum);
seatRes(seatNum);
printf("Seating Reservation");
printf("1 marks your reserved seat \n");
printf("------Movie 2 SEAT PLAN----------- \n");
seatNew(seatPlan);
priceComp(seatNum);
break;
case 3 :
printf("Movie 3 \n" );
printf("Seating Reservation \n" );
seatDisplay(seatPlan);
printf("How many seats would you like to reserve?: ");
scanf("%d", &seatNum);
seatRes(seatNum);
printf("Seating Reservation");
printf("1 marks your reserved seat \n");
printf("------Movie 3 SEAT PLAN----------- \n");
seatNew(seatPlan);
priceComp(seatNum);
break;
default:
printf("Invalid Input \n");
}
return 0;
getchar();
}
I'm studying C with converting C++ to C, but it doesn't moving.
I don't know C++ exactly but study it just for website.
I'm so thank you if you can help me, please...