CMPC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Gravity

3 posters

CMPC :: Computing :: Programming :: C++

Go down

Gravity Empty Gravity

Post by Admin Wed Dec 23, 2009 5:37 am

Create a program that finds the gravitational force acted upon between two given masses and a given distance.


AND I POSTED THIS IN THE C++ FORUM FOR A REASON Suspect


Last edited by Admin on Wed Dec 23, 2009 6:29 am; edited 1 time in total
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Gravity Empty Re: Gravity

Post by Admin Wed Dec 23, 2009 6:25 am

now i tried this myself. and i got the thing written up but i keep getting a damn error. so .... Razz


code is in spoiler

Spoiler:
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Gravity Empty Re: Gravity

Post by Admin Wed Dec 23, 2009 6:33 am

hmm i got an interesting idea. if i don't use the math library it compiles fine. wtf?

well here it is


edit: wait this doesn't work yet.... Razz gimme a sec...


edit: ok after tweaking around i found that if you enter a double into the DISTANCE variable, it screws up the program. .... wtf.?
Spoiler:
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Gravity Empty Re: Gravity

Post by Paul Wed Dec 23, 2009 8:33 pm

Code:

double compute(double m1, double m2, double d)
{
   
      static double G =.0000000000667428;
      double force=( G*( (m1*m2)/(d*d) ) );
      return force;
}

try this. . .

I'm not checking the code, I'm just correcting one BLATANT error
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

Gravity Empty Re: Gravity

Post by Admin Wed Dec 23, 2009 9:10 pm

when i enter a double for the value of distance, the console just disappears Razz i've had this problem before your correction and still afterwards.
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Gravity Empty Re: Gravity

Post by Paul Thu Dec 24, 2009 10:56 pm

Code:

double compute(double m1, double m2, double d)
{
      static double G =0.0000000000667428;
      double force=( G*( (m1*m2)/(d*d) ) );
      return force;
}
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

Gravity Empty Re: Gravity

Post by Lunsfordium Tue Aug 10, 2010 5:04 am

i love how you guys just post code willy-nilly without explanations
Lunsfordium
Lunsfordium
[Blankie]

Posts : 194

Back to top Go down

Gravity Empty Re: Gravity

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


CMPC :: Computing :: Programming :: C++

 
Permissions in this forum:
You cannot reply to topics in this forum