C++ භාවිතා කරලා Temperature Converter එකක් හදමු

maleesha udan

Well-known member
  • Jan 23, 2019
    206
    436
    63
    මේ ප්‍රෝග්‍රෑම් එකේදී අපි කතා කරමු කොහොමද 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;
    }
     
    • Like
    Reactions: hodakolla and NRTG

    CorD SaC

    Well-known member
  • Feb 4, 2015
    15,768
    28,130
    113
    1624988897406.png


    මේක යූස් කරන්න කෝඩ් දාද්දි