Using while or do-while. 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
Sum is : 8
No. 1: 3
No. 2: 2
One of the number entered is not ODD
#include<iostream>
using namespace std;
int main()
{
int Y,X;
cout<<"No.1:";
cin>>Y;
cout<<"No.1:";
cin>>X;
if(Y%2!=0&&X%2!=0){
int add=X+Y;
cout<<"Sum is: "<<add;}
else{
cout<<"No.2: ";
cin>>Y;
cout<<"No.2:";
cin>>X;
if(Y%2!=0&&X%2!=0){
int add=X+Y;
cout<<"Sum is: "<<add;
}
else{
cout<<"No.3: ";
cin>>Y;
cout<<"No.3:";
cin>>X;
if(Y%2!=0&&X%2!=0){
int add=X+Y;
cout<<"Sum is: "<<add;
}
}
}
}
Comments
Leave a comment