hey guys, trying my hand at user defined functions once again, and this program works!....... errrr, well........ depends on your definition of "works", lol, anyways, feel free to plug in my goofy ass program to your compiler and tell me what you think, i believe my math function may be written incorrectly, because the output is some sort of characters, definately not what im looking for in my output....... here it is, lemme know what im doing wrong, thanks guys...........
//program to convert light years to astronomical units
std::cout<< "Enter The Distance in Light Year(s):";
double lightyear;
std::cin>> lightyear;
double astronomical(double astronomical);
std::cout<< "Thats a distance of:"<< astronomical <<"units!"<<std::endl;
std::cout<<"Well, better get going because this will be a lonnnng trip!"<<std::endl;
#include <iostream>
// don't need <cmath>
//double lightyear (); // Never used.
double astronomical (double); // This is fine
int main()
{
std::cout << "Enter The Distance in Light Year(s): ";
double lightyear; // Shouldn't have a variable with the same name as a function
std::cin >> lightyear;
//double astronomical(double astronomical); // What is this? Delcaration?
// ^ You already declared a function above.
std::cout << "Thats a distance of: " << astronomical( lightyear ) << " units!" << std::endl;
// ^ How you correctly call the function. You are expecting it to return the value.
std::cout << "Well, better get going because this will be a lonnnng trip!" <<std::endl;
std::cin.get();
std::cin.get();
return 0;
}
double astronomical(double sts)
{
return 63,240 * sts;
}
ahhhh ok, coool, derrrp, yea my original issue was below the input i had defined astronomical again, figured that out and deleted it but then ran into this........ ok gotchya, thanks man, and definitely appreciate the comments, always helps when people explain what i did wrong instead of just correcting it