Write a c++ program that 1. Takes a numerical input from the user for a starting
ID: 670092 • Letter: W
Question
Write a c++ program that
1. Takes a numerical input from the user for a starting point
2. Takes a numerical input from the user for an ending point
3. From the provided starting point to the provided ending point:
a. Outputs “Multiples of “ and then outputs the number it is working on
b. Outputs each multiple of that number from the 1st up to the 10th multiple
4. Asks the user if they would like to try again with a different starting and ending number
Please explain each step in your code
Example output:
This program takes a starting number and ending number
and displays the 1st through the 10th multiple for each
number on the interval [starting number, ending number].
Please enter a starting number
> 3
Please enter an ending number
> 5
Multiples of 3
3 6 9 12 15 18 21 24 27 30 ...
Multiples of 4
4 8 12 16 20 24 28 32 36 40 ...
Multiples of 5
5 10 15 20 25 30 35 40 45 50 …
Would you like to do this again with a different starting
and ending value? (0=no, 1=yes)
> 0
Explanation / Answer
#include <iostream>
using namespace std;
void multiples()
{
int num1 ,num2,i,k;
cout << "Please enter a starting number:" << endl;
cin>>num1;
cout << "Please enter a ending number:" << endl;
cin>>num2;
for (i=num1;i<=num2;i++)
{
cout<<"Multiples of "<<i<< endl;
for(k=1;k<=10;k++)
{
cout<<i*k<<" ";
}
cout<<endl;
}
}
int main() {
multiples();
int num3;
cout<<"would you like to do this again with different Starting pt. and Ending Value? (0=No and 1=Yes)"<< endl;
cin>>num3;
if (num3==1)
multiples();
else
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.