View Code of Problem 42

#include<stdio.h>
int main(){
  int a,b,c,d,c1,c2;
  scanf("%d %d %d",&a,&b,&c);
  d=b*b-4*a*c;
  if(b>0){
  c1=-b+sort(d)/4*a;
  c1=-b-sort(d)/4*a;
    if(c1>c2)
      printf("%.2lf %.2lf",c1,c2);
    else
    printf("%.2lf %.2lf",c2,c1);
    
  }
  else{
  printf("ERROR");
  }
  
  return 0;
}
/*
Main.c: In function 'main':
Main.c:7:3: warning: implicit declaration of function 'sort' [-Wimplicit-function-declaration]
   c1=-b+sort(d)/4*a;
   ^
Main.c:10:7: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
       printf("%.2lf %.2lf",c1,c2);
       ^
Main.c:10:7: warning: format '%lf' expects argument of type 'double', but argument 3 has type 'int' [-Wformat=]
Main.c:12:5: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
     printf("%.2lf %.2lf",c2,c1);
     ^
Main.c:12:5: warning: format '%lf' expects argument of type 'double', but argument 3 has type 'int' [-Wformat=]
Main.c:9:7: warning: 'c2' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(c1>c2)
       ^
/tmp/ccVSuWl7.o: In function `main':
Main.c:(.text+0x60): undefined reference to `sort'
Main.c:(.text+0x93): undefined reference to `sort'
collect2: error: ld returned 1 exit status
*/

Double click to view unformatted code.


Back to problem 42