Question
please show procedure with ssh and emacs and explain the steps thanks
cp - cs12 s/newton.cpp yourfile.cpp Newton's law states that the force, F, between two bodies of masses M and M2 is given by: Mi M2 in which k is the gravitational constant and d is the distance between the bodies. The value of k is approximately 6.67 x 10 dyn. cm21g. The program is supposed to prompt the user to input the masses of the bodies and the distance between the bodies. The program then outputs the force between the bodies. Read through the program. Try to compile it. The program contains at least one semantic (logic) error and several syntax (grammar) errors. This assignment is designed to help you practice debugging a program. When a program will not compile, there are syntax errors in the source code. Try the following steps to locate and remove them. 1. Pay attention to the error list generated by the compiler. One error can produce a domino effect which leads to other errors, so do not panic if you see a very long list of problems. Fixing the first few will often eliminate many of the others. Read the first couple of messages, jot down or print the line numbers associated with each error. Compiler error messages are often vague. It will take time to get used to them. You can also redirect your error messages to a file The following command will send the messages to a file called errorlist. 2. gtt yourfile.cpp >&errorlist; In the lines shown below, the compiler thinks the errors described occurred on lines 17 and 23 newton.cpp: 17:error expected initializer before double' newton.cpp:23: error: 'Massl' was not declared in this scope 3. Open your program file (preferably in another window) with the emacs editor and go to the first line indicated as an error. Emacs will show you what line the cursor is on (bottom of window).
Explanation / Answer
working code for the same.
#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
float f,m1,m2,r;
cout<<"Enter the value of two masses in Kg : ";
cin>>m1>>m2;
cout<<"Enter the distance between two masses in meters : ";
cin>>r;
f=(6.67*pow(10.0,-11.0)*m1*m2)/(r*r);
cout<<"The force of attraction between two masses = "<<f<<" Newton ";
return 0;
}