Q: I am trying to solve maximum number of platforms for given number of bus using C. I got an error and stuck there I am trying to solve a maximum number of platforms for given number of  bus. I got an error and stuck there. 
I am getting an error:

"online_test.c:3:31: error: expected ';', ',' or ')' before 'arrivals'". 

Can anyone help me where I am making a mistake?
#include<stdio.h>

    static int findMinPlatforms(int[] arrivals, int[] departures, int bus){
        int no_of_platforms=0,low,high,max,i,j,min,arrival_i,departure_i;

        arrival_i=0;
        departure_i=0;
        for(i=0;((arrival_i<bus)&& (departure_i<bus));i++){

        //if(i>0){
            if (arrivals[arrival_i]<departures[departure_i]) {
                no_of_platforms=no_of_platforms+1;
                arrival_i+=1;
            } else(arrivals[arrival_i]<departures[departure_i]) { 
                no_of_platforms=no_of_platforms-1;
                departure_i+=1;
            }
        // }

        } 

       return no_of_platforms;
    }

    int main (void){
        int arrivals[]={901,941,951,1101,1530,1854};
        int departures[]={911,1201,1121,1133,1906,2003};
        int bus=6;
        printf("%d",findMinPlatforms(arrivals,departures,bus));
        return 0;
    }


A: The key here is to learn how to read and understand the compiler error:


*

*3:31 means line 3, symbol 31. Which points at []. 

*Even if you didn't get that number, the text "expected something else before arrivals" should point out the error.


In other words the compiler is telling you: "I don't know why you typed [] there, this isn't valid C, the C language expects you to type something else". And of course, the error is that an array parameter should be written as int arrivals[] and not int[] arrivals.

A: I had completed my logic for finding a maximum number of platforms at at a given time. 
#include<stdio.h>

  static int findMinPlatforms(int arrivals[], int departures[], int bus){
  int no_of_platforms=0,i,arrival_i,departure_i,max_platform=0;

  arrival_i=0;
  departure_i=0;
  for(i=0;((arrival_i<bus)&& (departure_i<bus));i++){


  //if(i>0){
  if ((arrivals[arrival_i]<departures[departure_i])){
  no_of_platforms=no_of_platforms+1;
  if(no_of_platforms>max_platform){
                     max_platform=no_of_platforms;
                 }
  //printf("i in array is %d\n",i);
  // printf("no of gates %d\n",no_of_platforms);
  // printf("least value for %d ind is %d and bus is %d\n",arrival_i,arrivals[arrival_i],bus);
  // printf("arrival bool %d\n",(arrival_i<bus)&& (departure_i<bus));
  if(arrival_i<bus){
  arrival_i+=1;
                 }
                 // printf("least value for %d ind is %d and bus is %d\n",arrival_i,arrivals[arrival_i],bus);
  }
  if(arrivals[arrival_i]>departures[departure_i]){

  no_of_platforms=no_of_platforms-1;
  if(no_of_platforms>max_platform){
                     max_platform=no_of_platforms;
                 }
  // printf("i in departure is %d\n",i);
  // printf("no of gates %d\n",no_of_platforms);
  // printf("least value %d ind is %d\n",departure_i,departures[departure_i]);
  // printf("departure_i bool %d\n",(arrival_i<bus)&& (departure_i<bus));
  if(departure_i<bus){
  departure_i+=1;
                 }

  // printf("least value %d ind is %d\n",departure_i,departures[departure_i]);
  }
  // printf("outside bool %d and %d\n",(arrival_i<bus), (departure_i<bus));
  // }




  } 

  return max_platform;
  }

  int main (void){
    int arrivals[]={800,840,850,1000,1400,1700};
    int departures[]={810,1100,1020,1030,1800,1900};
    int bus=6;
    printf("Maximum number of platforms is %d",findMinPlatforms(arrivals,departures,bus));
    return 0;
  }


  //answer Maximum number of platforms is 3

