Answer to Question #345732 in C++ for Wasfa

Question #345732

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)


1
Expert's answer
2022-05-30T08:15:37-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS