#include <iostream>

using namespace std;

int main()
{
    int a,b,c, ope;
    cout<<"enter a value" << endl;
    cin >> a;
    cout<<"enter b value" <<endl;
    cin >> b;
    cout<<"enter operation (+ - * / and %)";
    cin>> ope;
    if (ope == +)
    {
        c=a+b;
        cout<< c;
        break;
    }
    if (ope == -)
     {
        c=a-b;
        cout<< c;
        break;
     }
      else if (ope == *)
      {
          c=a*b;
      cout<< c;
        break;
      }
      else if (ope == /)
      {
       c= a/b;
       cout<< c;
       break;
      }
      else if (ope == %)
      {
        c=a%b;
        cout<< c;

      }
    else cout<<"entered wrong input";
    return 0;
}

whats wrong with the code its giving me so many errors.:confused:

ope should be a char

still getting so many errors

#include <iostream>

using namespace std; :'(

int main()
{
    int a,b,c;
    char ope;
    cout<<"enter a value" << endl;
    cin >> a;
    cout<<"enter b value" <<endl;
    cin >> b;
    cout<<"enter operation (+ - * / and %)";
    cin>> ope;
    if (ope == +)
    {
        c=a+b;
        cout<< c;
        break;
    }
    if (ope == -)
     {
        c=a-b;
        cout<< c;
        break;
     }
      else if (ope == *)
      {
          c=a*b;
      cout<< c;
        break;
      }
      else if (ope == /)
      {
       c= a/b;
       cout<< c;
       break;
      }
      else if (ope == %)
      {
        c=a%b;
        cout<< c;

      }
    else cout<<"entered wrong input";
    return 0;
}

its working only if i remove the break;. if i include it its showing break statement not within loop or switch.

//Instead of diclaring int a, b; rather declare float a, b; and yes for the operation ope declare as char ope; Please note that the compiler will give an error if you you put the modulus (%) operator in your code

This question has already been answered. Start a new discussion instead.