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

chamara4hera

Active member
  • Jul 30, 2016
    193
    179
    43
    Virtual machine ekaka ubuntu dala eken karanna. mukuth wena software ona na.
    terminal ekema compile karanna puluwan.
     

    සුදු පුතා

    Well-known member
  • Jul 4, 2014
    1,201
    658
    113
    වලස්ගුහාව.
    mama C try karala balanna GCC install karanna try kala MinGW walin. but kochchara path variable eka haduwath penwannema gcc -v ( 2.95) but man install kale ita godak aluth version ekak.
    meka MinGW install karanna kalin indalama thiyenawa. compile wenneth na. me gcc 2.95 version eka kohenda mage pc ekata awe? meka remove karaganna widiya kiyannako. google karala epa wela inne.
     

    beam_tech

    Well-known member
  • Oct 13, 2017
    8,010
    14,385
    113
    වැලිවේරිය
    mama C try karala balanna GCC install karanna try kala MinGW walin. but kochchara path variable eka haduwath penwannema gcc -v ( 2.95) but man install kale ita godak aluth version ekak.
    meka MinGW install karanna kalin indalama thiyenawa. compile wenneth na. me gcc 2.95 version eka kohenda mage pc ekata awe? meka remove karaganna widiya kiyannako. google karala epa wela inne.
    https://sourceforge.net/projects/orwelldevcpp/
     
    • Like
    Reactions: imhotep

    imhotep

    Well-known member
  • Mar 29, 2017
    14,866
    8
    35,456
    113
    This is another fork of Bloodshed Dev-C++... Very easy to use for beginners.

    Pls refer to what I wrote above....

    Just use Bloodshed C++
    https://www.bloodshed.net/

    You can use the original Dev C++ 5.0 or the later fork sponsored by Embarcadero.

    Embarcadero Dev-C++ is a new and improved fork of Bloodshed Dev-C++ and Orwell Dev-C++. It is a full-featured Integrated Development Environment (IDE) and code editor for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as its compiler. Embarcadero Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler. Embarcadero Dev-C++ is built using the latest version of Embarcadero Delphi. Embarcadero Dev-C++ has a low memory footprint because it is a native Windows application and does not use Electron.

    https://ftp.embarcadero.com/free-tools/dev-cpp
     

    lilman

    Well-known member
  • May 10, 2009
    41,034
    54,675
    113
    Colombo
    හරි අපි බලමු කොහොමද C ++ භාවිතා කරලා සරල / මුලික (Basic) Calculator එකක් හදා ගන්නේ කියලා

    මේ Calculator එක භාවිතා කරලා ඔයාලට Basic Arithmatic Operations වන

    1) එකතු කිරීම
    2) අඩුකිරීම
    3) ගුණකිරීම
    4) බෙදීම

    කියන ගණනයන් කරගන්න පුළුවන් . ඒවගේම මේකට cmath library එක එකතු කරලා නිසා ඔයාලට පුළුවන් යම් සංඛ්‍යාවක බලයක් හොයන්නත්.
    මේ cal එකේ source code පහලින් දාලා තියෙනවා.ඔයාලත් කැමතිනම් මේ source code, Codeblocks වගේ IDE එකක දාල run කරලා බලන්න

    (මේක Basic calculator එකක් විතරයි )


    #include<iostream>
    #include<cmath>
    using namespace std;
    int main(){
    double num1,num2;
    int op;
    cout<<"Enter the first number"<<endl;
    cin>>num1;
    cout<<"Enter the second number"<<endl;
    cin>>num2;
    cout<<"Enter the arithmetic operation"<<endl;
    cout<<"1 Addition"<<endl;
    cout<<"2 Subtraction"<<endl;
    cout<<"3 Multiplication"<<endl;
    cout<<"4 Division"<<endl;
    cout<<"5 Power"<<endl;
    cout<<"Enter the number"<<endl;
    cin>>op;
    cout<<" "<<endl;
    switch(op){
    case 1: cout<<(num1+num2)<<endl;
    break;
    case 2: cout<<(num1-num2)<<endl;
    break;
    case 3: cout<<(num1*num2)<<endl;
    break;
    case 4:{
    if(num2==0)cout<<0<<endl;
    else cout<<(num1/num2)<<endl;
    }
    break;
    case 5:cout<<pow(num1,num2)<<endl;
    break;
    default :cout<<"Invalid operation"<<endl;
    }
    return 0;
    }




    Thank you! 😉

    C++:
    #include<iostream>
    
    #include<cmath>
    
    using namespace std;
    int main() {
      double num1, num2;
      int op;
      cout << "Enter the first number" << endl;
      cin >> num1;
      cout << "Enter the second number" << endl;
      cin >> num2;
      cout << "Enter the arithmetic operation" << endl;
      cout << "1 Addition" << endl;
      cout << "2 Subtraction" << endl;
      cout << "3 Multiplication" << endl;
      cout << "4 Division" << endl;
      cout << "5 Power" << endl;
      cout << "Enter the number" << endl;
      cin >> op;
      cout << " " << endl;
      switch (op) {
      case 1:
        cout << (num1 + num2) << endl;
        break;
      case 2:
        cout << (num1 - num2) << endl;
        break;
      case 3:
        cout << (num1 * num2) << endl;
        break;
      case 4: {
        if (num2 == 0) cout << 0 << endl;
        else cout << (num1 / num2) << endl;
      }
      break;
      case 5:
        cout << pow(num1, num2) << endl;
        break;
      default:
        cout << "Invalid operation" << endl;
      }
      return 0;
    }

    Mehema format karanna puluwan syntax highlighting ekka aluth ek eke. indenting nm kalin karala tiyenne one mng hitanne.
    Anyway good post keep it up!
    උප්
     
    • Like
    Reactions: SagaxConatusV