1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Please help with these errors

Discussion in 'C' started by DP1990, Mar 6, 2011.

  1. DP1990

    DP1990 New Member

    Joined:
    Mar 6, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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 : ')'
     
  2. DRK

    DRK New Member

    Joined:
    Apr 13, 2012
    Messages:
    44
    Likes Received:
    3
    Trophy Points:
    0
    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)
     
  3. mthushara

    mthushara New Member

    Joined:
    Aug 4, 2009
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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
     

Share This Page