Topic: [new user] Compile/build a pure C code (How to?/Examples?)
Hello,
I am a new user of SF.
I could successfully compile Fortran code. I would like now to compile a pure C code. I tried it with a simple code (see below) but it didn't work. Could you please give me a feedback, why this simple code doesn't work?
Thank you in advance,
Peter
/* Program quad_root.c */
#include <math.h>
main(){
float a, b, c;
float xl, x2;
float D;
printf("Enter coefficient a:");
scanf("%f",&a);
/* test for quadratic */
if (a==0){
printf("Illegal quadratic!\n");
exit(0) ;
}
printf("Enter coefficient b:");
scanf("%f",&b);
printf("Enter coefficient c: " ) ;
scanf("%f",&c);
/* Compute argument for square root and
test for complex roots */
D = b*b - (4*a*c);
if(D < 0){
printf("complex roots! \n");
exit(0);
}
/* Compute roots of quadratic*/
xl = (-b-sqrt(D))/2*a);
x2 = (-b+sqrt(D))/(2*a);
/* Output the results*/
printf("xl = %f\n",xl);
printf("x2 = %f\n",x2);
exit(0);
}