මේ ප්රෝග්රෑම් එකේදී අපි කතා කරමු කොහොමද C++ භාවිතා කරලා Celsius Farhenheit කරන්නත් Farhenheit Celsius කරන්නත් පුළුවන් සරල TemperatureConverter හදන්නේ කියලා
මේකෙදි Function දෙකක් පාවිච්චි කරලා තමයි මන් මේක හැදුවේ
//source code
#include<iostream>
using namespace std;
void fahren();
void celsius();
int main(){
int op;
cout<<"Select your Function....."<<endl;
cout<<"1 Convert Celsius to Fahrenheit"<<endl;
cout<<"2 Convert Fahrenheit to Celsius"<<endl;
cout<<""<<endl;
cout<<"Enter the number"<<endl;
cin>>op;
if(op==1) fahren();
else if(op==2)celsius();
else cout<<"!!!INVALID OPTION PLEASE TRY AGAIN"<<endl;
return 0;
}
void fahren(){
double tem,temp;
cout<<"Enter the Celsius temperature"<<endl;
cin>>tem;
temp=(tem*9/5)+32;
cout<<temp<<" F"<<endl;
}
void celsius(){
double tem,temp;
cout<<"Enter the Fahrenheit temperature"<<endl;
cin>>tem;
temp=(tem-32)*5/9;
cout<<temp<<" C"<<endl;
}
මේකෙදි Function දෙකක් පාවිච්චි කරලා තමයි මන් මේක හැදුවේ
//source code
#include<iostream>
using namespace std;
void fahren();
void celsius();
int main(){
int op;
cout<<"Select your Function....."<<endl;
cout<<"1 Convert Celsius to Fahrenheit"<<endl;
cout<<"2 Convert Fahrenheit to Celsius"<<endl;
cout<<""<<endl;
cout<<"Enter the number"<<endl;
cin>>op;
if(op==1) fahren();
else if(op==2)celsius();
else cout<<"!!!INVALID OPTION PLEASE TRY AGAIN"<<endl;
return 0;
}
void fahren(){
double tem,temp;
cout<<"Enter the Celsius temperature"<<endl;
cin>>tem;
temp=(tem*9/5)+32;
cout<<temp<<" F"<<endl;
}
void celsius(){
double tem,temp;
cout<<"Enter the Fahrenheit temperature"<<endl;
cin>>tem;
temp=(tem-32)*5/9;
cout<<temp<<" C"<<endl;
}