Question #264782

Make a program that will input two number, If the two number entered are ODD then perform the addition and display the Sum. Your program will be terminated by an option if the user not to proceed another entry.

Ex, No. 1: 5 No. 2: 3

No. 1: 3

No. 2: 2

Sum is : 8

One of the number entered is not ODD


Expert's answer

#include <iostream>


using namespace std;


int main()
{
    while(true){
        int num1;
        int num2;
        
        cout<<"\nEnter two numbers: ";
        cin>>num1>>num2;
        
        int sum;
        if(num1%2!=0 && num2%2!=0){
            sum=num1+num2;
            cout<<"\nSum: "<<sum;
        }
        else{
            cout<<"\nOne of the number entered is not ODD";
            break;
        }
      
    }
    return 0;
}

LATEST TUTORIALS
APPROVED BY CLIENTS