c++之函数的调用

时间:2022-09-22 09:04:14
#include<iostream>
#include<math.h>


using namespace std;


void output(double light_year,double astronomical_units);


int main()
{
double light_year;
double astronomical_units;
cout<<"Enter the number of light years  : ";
cin>>light_year;
output(light_year,astronomical_units);//函数的调用必须见参数填入,可以不填参数类型,否则报错 
cout<<light_year<<" light years = "<<astronomical_units<<" astronomical units "<<endl;


}
void output(double light_year,double astronomical_units) 
{
    astronomical_units=light_year*63240;
    
}