Question #30166

i have home task can u guide me .take input of two numbers,until both number are divisble by 2 and three.it ask u to take input again and again when result comes .it show table of both numbers.....plzz

Expert's answer

// 11.cpp : Defines the entry point for the console application.
//

#include <iostream>

using namespace std;

int main()
{
int n1, n2; // numbers for entering
do // using do-while construction
{
cout << "---Please enter the numbers---\n"; // asking for entering
cout << "first number: ";
cin >> n1; // enter 1-st number
cout << "second number: ";
cin >> n2; // enter 2-nd number
}
while ( (n1 % 3 != 0) || (n1 % 2 != 0) || (n2 % 3 != 0) || (n2 % 2 != 0) ); // test for divisibility by 2 and 3.
//We do all that are calling in do{} until condition in while became false.
cout << "You entered: " << n1 << " and " << n2 << ".\n"; // write result
}
LATEST TUTORIALS
APPROVED BY CLIENTS