Write a program in C++ to scan two integers and add them if both are positive, multiply them if both are negative, subtract the smaller number from the bigger if both have different signs.

Write a program in C++ to scan two integers and add them if both are positive, multiply them if both are negative, subtract the smaller number from the bigger if both have different signs.
 # include <iostream>
using namespace std;
int main(){
       int a, b;
       cout << "Enter Number" << endl;
       cin >> a;
       cout << "Enter Number" << endl;
       cin >> b;
       if (a >= 0 && b >= 0){
              a = a + b;
              cout << "Sum of the numbers is " << a << endl;
       }
       else{
              if (a <= 0 && b <= 0){
                     a = a*b;
                     cout << "Multipaction of the numbers is " << a << endl;
              }
              else{
                     int c, d;
                     if (a < 0 && b>0){
                           a = b - a;
                           cout << "Substraction of the numbers is " << a << endl;

                     }
                     else{
                           a = a - b;
                           cout << "Substraction of the numbers is " << a << endl;
                     }

             
              }
       }
       system("pause");
       return 0;

}


Comments