+ 5
This line: double moon_g(); doesn't actually doanything, it just states that a function double moon_g() exists. What you want is something like this: double weight = moon_g(); cout << "Weight is " << weight << endl; This won't work yet, because you don't have a function double moon_g(), what you have is a function double moon_g(double a, double b). But those arguments aren't really used for anything (well, they are, but there's no reason to have them passed in as arguments). So eliminate them from your function like so: double moon_g() { cout<<"Enter the mass in kilograms. Use decimal point for any number entered"; double a; cin>>a; double b=(17*9.8)/100; double mg=a*b; return mg; } (And declare the function before you call it.) More refinements are possible, but that'll be enough for now. ↓↓↓ :) https://stackoverflow.com/questions/20916162/calling-a-function-in-main
20th Dec 2017, 7:43 PM
James16
James16 - avatar