NESTED LOOP PROBLEM:)
Design an interactive input loop that scans pairs of integers until it reaches a pair in
which the first integer evenly divides the second. Produce the output in the same format
given below.
Expected Output:
Input number pair 1: 4 7
Input number pair 2: 3 16
Input number pair 3: 14 7
Input number pair 4: 10 100
Your desired number pair is (10,100)
#include <iostream>
using namespace std;
int main() {
int num1, num2;
for (int i = 0; true; i++){
cout << "Input number pair "<<i+1<<": ";
cin>>num1>>num2;
if(num2%num1==0){
cout<<"Your desired number pair is ("<<num1<<","<<num2<<")"<<endl;
break;
}
}
return 0;
}
Comments
Leave a comment