Home > Back-end >  why this error coming when compiling how to solve implicit declaration of function?
why this error coming when compiling how to solve implicit declaration of function?

Time:10-16

    #include<stdio.h>
    #include<math.h>
    float val [4][2],a[4];
    int j,i,y;
    
    float cordianation_entry() {  
        printf("enter your cordianation-");
        scanf("%f,%f",&val[0][0],&val[0][1]);
        for(j=1;j<4;j  ) {
            printf("enter station %d coordination-",j);
            scanf("%f,%f",&val[j][0],&val[j][1]);
       }    
    }
    
    float results_analysis() {
      
       for(i=1;i<4;i  ) { 
        a[i] = (pow((val[i][0]-val[0][0]),2))   (pow((val[i][1]-val[0][1]),2));
        a[i]=sqrt(a[i]);
        printf("\n*distance to station %d is %f\n",i,a[i]);
        if(a[i]<100)
        printf("\tDistance is Low");
        else if(a[i]<1000 && a[i]>=100)
        printf("\tDistance is Moderate");
        else 
        printf("\tDistance is High");
       }

compiler dose not read this minimum function
float minimum() {

        if(a[1]<a[2]&&a[1]<a[3])
        printf("station 1 is the nearest");
        else if(a[2]<a[3]&&a[2]<a[1])
        printf("station 2 is the nearest");
        else if(a[3]<a[1]&&a[3]<a[2])
        printf("station 2 is the nearest");
    }
    
    
    
    
    }
    

compiler dose not detect minimum function how to solve it
when it compile it shows an error message impilicit decleration of function minimum

void main() {   
   cordianation_entry();
   results_analysis();
   minimum();
}

CodePudding user response:

The problem is you did not use {} parenthesis correctly. In particular this function:

float results_analysis() {
  
   for(i=1;i<4;i  ) { 
    a[i] = (pow((val[i][0]-val[0][0]),2))   (pow((val[i][1]-val[0][1]),2));
    a[i]=sqrt(a[i]);
    printf("\n*distance to station %d is %f\n",i,a[i]);
    if(a[i]<100)
    printf("\tDistance is Low");
    else if(a[i]<1000 && a[i]>=100)
    printf("\tDistance is Moderate");
    else 
    printf("\tDistance is High");
   }
}   // <--- Missing in your code

and there is a } parenthesis that is not supposed to be there:

float minimum() {

    if(a[1]<a[2]&&a[1]<a[3])
    printf("station 1 is the nearest");
    else if(a[2]<a[3]&&a[2]<a[1])
    printf("station 2 is the nearest");
    else if(a[3]<a[1]&&a[3]<a[2])
    printf("station 2 is the nearest");
}

// }  <--- Wrong 
  • Related