3

I am trying to use the % modulo in a simple calculator which used the merge of double and int variable which is already declared in the code. I am using this way because by using Double variables with " modulo % " is not possible according to my knowledge.

 #include <iostream>
    using namespace std;
    main()
    {
    double variable1, variable2;
    int variable3 = variable1, variable4 = variable2;
    beginning:
    system ("cls");
    cout << "Enter the First Number" << endl;
    cin >> variable1;
    cout << "Enter the Second number" << endl;
    cin >> variable2;
    cout << "What do you want to use?" << endl;
    cout << " + Addition can be use " << endl;
    cout << " - Subtraction can be use " << endl;
    cout << " * Multiplication can be use " << endl;
    cout << " / Division can be use " << endl;
    cout << " % Modulo can be use " << endl;
    char decision;
    cin >> decision;
    switch (decision)
    {
    case '+':
        cout << variable1 << "+" << variable2 << "=" << (variable1 + variable2) << endl;
    break;
    case '-':
        cout << variable1 << "-" << variable2 << "=" << (variable1 - variable2) << endl;
    break;
    case '*':
        cout << variable1 << "*" << variable2 << "=" << (variable1 * variable2) << endl;
    break;
    case '/':
    if (variable2 != 0)
        cout << variable1 << "/" << variable2 << "=" << (variable1 / variable2) << endl;
        else
            cout << "You can't divide by zero" << endl;
    break;
    case '%':
        cout << variable1 << "%" << variable2 << "=" << (variable3 % variable4) << endl;
    break;
    default:
    cout << "You have entered incorrect data";
    }
    cout << "Do you want to continue using the Calculator? (Y/N)" << endl;
    char decision2;
    cin >> decision2;
    if (decision2 == 'y' || decision2 == 'Y')
    goto beginning;

}
Саша
  • 837
  • 4
  • 12
  • 2
    Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/206941/discussion-on-question-by--is-it-possible-to-merge-double-variables-with-int). – Cody Gray - on strike Jan 30 '20 at 21:42

0 Answers0