Using while or do-while loop. Make a program that will input two number, If the two number entered are EVEN then perform the addition and display the Sum. Your program will be terminated by an option if the user not to proceed another entry.
#include <iostream>
int main()
{
int firstNumber;
int secondNumber;
char choise{ 'Y' };
do
{
std::cout << "Enter first integer number : ";
std::cin >> firstNumber;
std::cout << "Enter second integer number : ";
std::cin >> secondNumber;
if (firstNumber % 2 == 0 && secondNumber % 2 == 0)
std::cout << "Sum of even numbers: " << firstNumber + secondNumber << "\n";
std::cout << "Continue (Y/n) ";
std::cin >> choise;
} while (choise != 'n');
return 0;
}
Comments
Leave a comment