Code: #include <stdio.h> #include<stdlib.h> #define MAX 6 int add (int t_array[], int f, int r, int max, int added_t); int main() { int taxi_array[MAX]; int menu = 0; int front = -1; int rear = -1; int addedTaxi; // Loop for Menu while ( menu <= 8 ) { return 0; //Menu for User printf("-------------------------------\n"); printf("Please Select an option from the menu.\n"); printf("1. arrive: Add a taxi to the rear of the queue.\n"); printf("-------------------------------\n"); scanf_s("%d",&menu); switch (menu) // Menu System for the Taxi Queue { case 1: //Enter Taxi Registration Number to the Queue add(taxi_array, front, rear, MAX, addedTaxi); break; default: break; } } } int add(int taxi_array[], int front, int rear, int MAX, int addedTaxi) { if (rear==MAX-1) { printf("Taxi Rank Full\n"); } else (front==-1) //If queue is initially empty { front=0; printf("Input the reg of the new taxi\n"); scanf_s("%d", addedTaxi); rear=rear+1; taxi_array[rear] = addedTaxi; prinf("The follow taxi has joined the queue: %s \n", addedTaxi); } }//End of add Errors: (50) : error C2143: syntax error : missing ')' before 'constant' (50) : error C2143: syntax error : missing '{' before 'constant' (50) : error C2059: syntax error : '<Unknown>' (50) : error C2059: syntax error : ')'
Code: int add(int taxi_array[], int front, int rear, int [COLOR="Red"]max[/COLOR], int addedTaxi) Code: else [COLOR="red"]if[/COLOR] (front==-1)
Code: #include <stdio.h> #include<stdlib.h> #define [B][COLOR="Red"]MAX[/COLOR][/B] 6 //int add (int t_array[], int f, int r, [B][COLOR="red"]int max[/COLOR][/B], int added_t); [COLOR="red"]//no need to pass max, since u pass MAX which is global int add (int t_array[], int f, int r, int added_t); [/COLOR] int main() { int taxi_array[MAX]; int menu = 0; int front = -1; int rear = -1; int addedTaxi; // Loop for Menu while ( menu <= 8 ) { //bellow line will exit the program //return 0; //Menu for User printf("-------------------------------\n"); printf("Please Select an option from the menu.\n"); printf("1. arrive: Add a taxi to the rear of the queue.\n"); printf("-------------------------------\n"); scanf_s("%d",&menu); switch (menu) // Menu System for the Taxi Queue { case 1: //Enter Taxi Registration Number to the Queue //add(taxi_array, front, rear, [COLOR="red"]MAX,[/COLOR] addedTaxi); add(taxi_array, front, rear, addedTaxi); break; default: break; } } [COLOR="red"]return 0;[/COLOR] } //int add(int taxi_array[], int front, int rear, [COLOR="red"]int MAX[/COLOR], int addedTaxi) int add(int taxi_array[], int front, int rear, int addedTaxi) { if (rear==MAX-1) { printf("Taxi Rank Full\n"); } else if(front==-1) //If queue is initially empty { front=0; printf("Input the reg of the new taxi\n"); scanf_s("%d", addedTaxi); rear=rear+1; taxi_array[rear] = addedTaxi; prinf("The follow taxi has joined the queue: %s \n", addedTaxi); } [COLOR="red"] return 0; //return some value[/COLOR] }//End of add