solve it in c++ please i need the codes to copy and paste in microsoft world Exe
ID: 3891787 • Letter: S
Question
solve it in c++ please i need the codes to copy and paste in microsoft worldExercise #2: Factors Write a program that prompts the user to enter two positive integers m and n, then output all factors of each integer in the given range, inclusive. Print in a similar format to the format given below Sample input / output: Enter two positive integers: 18 27 factors 18 18 19 2e 21 19 1 2 451 2 1 3 721 1 2 1122 1 23 1 2346 8 12 24 1 525 23 24 25 26 27 13 26 1 3 9 27 Exercise #3: Calculate the Value of Pi
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int x,y;
cout << "Enter two positive integers:" << endl;
cin >> x>>y;
cout<<"i | factors"<<endl;
cout<<"*********************************************"<<endl;
for(int i=x;i<=y;i++) {
cout<<i<<" |";
for(int j=1;j<=i;j++) {
if(i%j==0){
cout<<j<<" ";
}
}
cout<<endl;
}
return 0;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.