Change this C++ code so the user is prompt with(Y or N) instead of 1 to continue.
#include <iostream>
using namespace std;
bool isMulitple(int n1,int n2){
return n1%n2==0;
}
int main()
{
int c=1;
int n1,n2;
while(c==1){
cout<<“Enter 2 numbers: “;
cin>>n1;
cin>>n2;
if(isMulitple(n1,n2))
cout<<n1<<“,”<<n2<<” are mulitples of eachothern”;
else
cout<<n1<<“,”<<n2<<” are not mulitple ofeach other n”;
cout<<“Press 1 to continue ,any other key to exit: “;<—– Change this to (Y or N)prompt
cin>>c;
}
}
Answer
#include <iostream>using namespace std;bool isMulitple(int n1,int n2){return n1%n2==0;}int main(){char c = ‘Y’;int n1,n2;while(c==’Y’){cout<<“Enter 2 numbers: “;cin>>n1;cin>>n2;if(isMulitple(n1,n2))cout<<n1<<“,”<<n2<<” are mulitples of each othern”;elsecout<<n1<<“,”<<n2<<” are not mulitple of each other n”;cout<<“Press (Y or N) to continue ,any other key to exit: “; cin>>c;}}
nter