The online racing simulator
C programming help [solved]
(3 posts, started )
C programming help [solved]
Hi guys,
Im just making a little program that tells you how close an astroid will come to earth, if you give x,y co-ordinates.
Well, thats not revelent...

I get these 2 errors when i got to compile it:
In function `int main()':
invalid operands of types `double*' and `double' to binary `operator&'

#include <stdio.h>
#include <math.h>
#include <conio.h>

int main()

{
//declarations
double x,y,r,a,b,c,d,distance;

//inputs
printf("please enter the position of the planet (x,y):"); scanf("%lf %lf", &x &y);
printf("Enter planet radius:");scanf("%lf",&r);
printf("Please enter linear trajectory (ax+by+c=0) of asteroid (a,b,c):"); scanf("%lf%lf%lf", &a,&b,&c);
distance=fabs(a*x+b*y+c)/sqrt(a*a+b*b);
d=distance-r;
printf("The asteroid will pass within %lf of the planet.",d);
getch();
return 0;
}

For more info on the question, go here: http://elm.eeng.dcu.ie/~oconaire/ioi2008/round1/


And if anybody could reply to this quickly, it would be greatly appreciated as I have to have it submitted it by tomorrow


Thanks
You're missing a comma between &x and &y on line 12.

And for the LOVE OF GOD learn to put things on separate lines

#include <stdio.h>
#include <math.h>
#include <conio.h>

int main()

{
//declarations
double x, y, r, a, b, c, d, distance;

//inputs
printf("please enter the position of the planet (x,y):");
[B]scanf("%lf %lf", &x, &y);[/B]
printf("Enter planet radius:");
scanf("%lf",&r);
printf("Please enter linear trajectory (ax+by+c=0) of asteroid (a,b,c):");
scanf("%lf%lf%lf", &a,&b,&c);
distance=fabs(a*x+b*y+c)/sqrt(a*a+b*b);
d=distance-r;
printf("The asteroid will pass within %lf of the planet.",d);
getch();
return 0;
}

Quote from the_angry_angel :You're missing a comma between &x and &y on line 12.

And for the LOVE OF GOD learn to put things on separate lines


Oi!

Thanks mate, very quick indeed

C programming help [solved]
(3 posts, started )
FGED GREDG RDFGDR GSFDG