Skip to content

Instantly share code, notes, and snippets.

@radamant
Created April 14, 2013 02:22
Show Gist options
  • Save radamant/5381106 to your computer and use it in GitHub Desktop.
Save radamant/5381106 to your computer and use it in GitHub Desktop.
#include <iostream>
#define ASTRO_UNITS_PER_LIGHT_YEAR 63240
float lightYearsToAstronomicalUnits(float);
int main()
{
using namespace std;
cout << "Enter the number of light years: ";
float lightYears;
cin >> lightYears;
cout << lightYears << " light years = "
<< lightYearsToAstronomicalUnits(lightYears)
<< " astronomical units." << endl;
return 0;
}
float lightYearsToAstronomicalUnits(float lightYears)
{
return lightYears * ASTRO_UNITS_PER_LIGHT_YEAR;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment