1. ## Help me get this to work please

Code:
```#include <stdio.h>
#include <math.h>

int main()

{

float r, F, G, m1, m2;
float gravitationalforce;

/*
* User inputs the distance & mass of the two objects.
*/

printf("Enter the mass of the two object 2: ");
scanf("%f, &m1,");

printf("Enter the mass of the object 2: ");
scanf("%f, &m2");

printf("Enter the distance of the object: ");
scanf("%f, &r");

/*
* Distance and mass is inputted.
*/

gravitationalforce = 6.674e-11;

printf("\nGravitational force : %20f ",F);

/*
* Values inputted provide gravitational force.
*/

return(0);
}```
Not sure how to input the F = G m1*m2 / r^2 part

2. Have you worked with arithmetic operators?
If so, just apply them to the variables as indicated.

Code:
```// example:

int a = 4;
int b = 5;
int product = a * b;```
It might be easier for you to use temporary variables and calculate each piece separately, rather than trying to write out the entire equation in one line.

Also, you have some syntax errors in your program. It is very helpful to compile and test your code often. For instance, before going any further with the equation, just read the inputs and print them back out, fixing any errors (if present). When that part works, move on to the equation portion of the assignment.

This is wrong:

Code:
`scanf("%f, &m1,");`
It should look like this:

Code:
`scanf("%f", &m1);`
Note the location of the quotes and comma.

4. Originally Posted by Matticus

This is wrong:

Code:
`scanf("%f, &m1,");`
It should look like this:

Code:
`scanf("%f", &m1);`
Note the location of the quotes and comma.
I got it working thanks

5. Newton's Law program

Newton's Law program - C++ Forum

or
Computational Physics - modelling the two-dimensional gravitational p…

its in c++ so you'll have to maybe convert it, maybe not. depends

6. The OP simply has to express the equation in code. There's no need for them to copy and/or convert existing code. We should be encouraging people to solve problems themselves, not offer copy/paste solutions.

7. it is not like he cannot learn by example as the post show how tos. if we write it or someone else does, who is to say he will not copy paste whatever it posted in here? it is the same thing, just the source has changed.

8. Originally Posted by userxbw
it is not like he cannot learn by example as the post show how tos.
One learns programming much better by manually typing all of their code, and attempting to solve the problem themselves. "Learning by example" is not beneficial at this stage. They need to try walking all on their own - using a crutch this early on makes it harder to progress.

Originally Posted by userxbw
if we write it or someone else does, who is to say he will not copy paste whatever it posted in here?
That is why we do not provide solutions, or links to complete solutions. It is more helpful to the learning process to guide people towards a solution.

It's very easy for many of us to write these beginner programs. It's much harder to craft a response that will give the person a push in the right direction without giving away the answer.

9. Originally Posted by Matticus
One learns programming much better by manually typing all of their code, and attempting to solve the problem themselves. "Learning by example" is not beneficial at this stage. They need to try walking all on their own - using a crutch this early on makes it harder to progress.

That is why we do not provide solutions, or links to complete solutions. It is more helpful to the learning process to guide people towards a solution.

It's very easy for many of us to write these beginner programs. It's much harder to craft a response that will give the person a push in the right direction without giving away the answer.
helping someone, or just giving that person a solution to their problem as long as one learns that is all that matters. if they cheat
themselves then they have done just that. someone that is in college better should have leaned that lesson by then.

if one sees the solution to the problem it too can help one better understand the how to get to it the next time. instead of making that other struggle to no end.

we are suppose to be making life easier for the other. Not the other way around. people all learn differently, who is to say they cannot learn by examples and seeing solutions to the problem?

they even put the solution to the problems in the teachers book. they, the powers that be do not make the teacher do all of the work. they instead give them the solutions to what problems they are to give out to the others. therefore by that means even the student can do that part of the teachers job.

as far as copy and past instead of repetition by typing it out so one will remember what to write. that is called what?

as far as what I did in here he still have to understand the math behind it, it is all Newton's Law that part does not change. seeing what functions to use to do the math. no telling (showing ) him (someone) what to do so he (they) can see how to do it, nothing wrong with that.

here just point you to the air plane, tell you how to turn it on, then leave the rest up to you to figure out.

an inquisitive mind will keep asking questions until he or she has the answers he or she seeks. by hook or crook.

10. Originally Posted by userxbw
helping someone, or just giving that person a solution to their problem as long as one learns that is all that matters.
It is not wise to become a homework solution service, and that is more likely to happen when complete answers to what are obviously homework questions are handed out on a plate.

Originally Posted by userxbw
if they cheat
themselves then they have done just that. someone that is in college better should have leaned that lesson by then.
That is true, but then sometimes it can be difficult to do things substantially differently after seeing a complete solution to a problem, in which case the student would be faced with the dilemma of choosing between plagiarism (minor modifications are insufficient to excuse this) or to continue to try finding a different (and possibly inferior) solution to the homework problem.

Originally Posted by userxbw
we are suppose to be making life easier for the other. Not the other way around. people all learn differently, who is to say they cannot learn by examples and seeing solutions to the problem?
Hence, feel free to post solutions to similiar problems, e.g., a variation of the problem posed such that the student has to understand the solution to come up with a similiar solution to the original problem, or perhaps a simplified version of the original problem to demonstrate some critical idea in the problem solving method. It may also help if you explained in prose the ideas behind your solution to the alternative problem.