View Code of Problem 42

#include<stdio.h>
#include<math.h>
int main(){
float a,b,c,x1,x2;
  scanf("%d%d%d",&a,&b,&c);
  x1=(b+sqrt(b*b-4*a*c))/(2.0*a)
    x2=(b-sqrt(b*b-4*a*c))/(2.0*a)
    printf(“%.2f %.2f”,x1,x2);
    return 0;
}
/*
Main.c: In function 'main':
Main.c:5:3: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'float *' [-Wformat=]
   scanf("%d%d%d",&a,&b,&c);
   ^
Main.c:5:3: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'float *' [-Wformat=]
Main.c:5:3: warning: format '%d' expects argument of type 'int *', but argument 4 has type 'float *' [-Wformat=]
Main.c:7:5: error: expected ';' before 'x2'
     x2=(b-sqrt(b*b-4*a*c))/(2.0*a)
     ^
Main.c:8:5: error: stray '\342' in program
     printf(“%.2f %.2f”,x1,x2);
     ^
Main.c:8:5: error: stray '\200' in program
Main.c:8:5: error: stray '\234' in program
Main.c:8:5: error: stray '\342' in program
Main.c:8:5: error: stray '\200' in program
Main.c:8:5: error: stray '\235' in program
Main.c:8:5: error: stray '\357' in program
Main.c:8:5: error: stray '\274' in program
Main.c:8:5: error: stray '\233' in program
Main.c:4:16: warning: unused variable 'x2' [-Wunused-variable]
 float a,b,c,x1,x2;
                ^
Main.c:4:13: warning: variable 'x1' set but not used [-Wunused-but-set-variable]
 float a,b,c,x1,x2;
             ^
*/

Double click to view unformatted code.


Back to problem 42