Ok,
I have been confused for a while on this:
What is wrong with using void?
Why is wrong to use 'void main()'?
Is it okay to use 'void' for your functions?
For example:
Is it okay to do what I just did?PHP Code:
// Tempature converstions
#include <iostream.h>
void to_celsius(float f);
void to_fahrehiet(float c);
int main()
{
char quit;
char selection[100];
float temp;
quit = '/0';
cout<< " _________________________________________________ "<<endl;
cout<< " Welcome to 'Calculations For Lazies' (Version 1.0) "<<endl;
cout<< " ------------------------------------------------- "<<endl;
cout<< " ------------------------------------------------- "<<endl;
cout<<endl;
cout<< " Celsius/Farhenheit converter:"<<endl;
cout<< " ______________________________"<<endl;
while (quit != 'q')
{
cout << "1- Fahrenhiet to Celsius "<<endl;
cout << "2- Celsius to Fahrenhiet "<<endl;
cout << "3- To quit "<<endl;
cout << '\n';
cout << "Please select an option number: ";
cin >> selection;
switch (selection, 100)
{
case 1:
cout <<"Enter the Fahrenhiet temperature you would like to convert: ";
cin >> temp;
to_celsius(temp);
break;
case 2:
cout <<"Enter the Celsius temperature you would like to convert: ";
cin >> temp;
to_fahrehiet(temp);
break;
case 3:
quit = 'q';
default:
cout << '\n';
cout << '\n';
break;
}
}
return 0;
}
void to_celsius(float f)
{
float conversion;
conversion = (f - 32)/1.8;
cout <<f<<" Degrees Fahrenhiet = "<<conversion<<" Degrees Celsius."<<endl;
cout << '\n';
}
void to_fahrehiet(float c)
{
float conversion;
conversion = c * 1.8 + 32;
cout <<c<<" Degrees Celsius = "<<conversion<<" Degrees Fahrenhiet."<<endl;
cout << '\n';
}