Question

Problem: Write a program to calculate the force of gravitational attraction between two objects of known mass at a known dist

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

#include <iostream>
#include<iomanip>
using namespace std;

int main()
{
const double G=6.67e-11;
double d,m1,m2,F;
cout<<"Please enter the mass of first object in kgs: ";
cin>>m1;
cout<<"Please enter the mass of second object in kgs: ";
cin>>m2;
cout<<"Now, enter distance between objects in meters: ";
cin>>d;
F=G*m1*m2/(d*d);
cout<<fixed;
cout<<scientific;
cout<<"For an object of mass: "<<setprecision(2)<<m1<<" kgs and another of mass: "<<setprecision(2)<<m2<<" kgs at a distance of "<<setprecision(2)<<d<<" meters\n";
cout<<"The gravitational force is "<<setprecision(2)<<F<<" Newtons\n";
  
return 0;
}

M Inbox (1) - gurkaranpre x C Computer Science ques X Online C++ Compiler - X C My Q&A | Chegg.com x C My Q&A | Chegg.com ~ K

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Problem: Write a program to calculate the force of gravitational attraction between two objects of known...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT