Answer:
#include <iostream>
using namespace std;
void printmultiples(int n) //function to print first five multiples between 3168 and 376020
{
int a =3168,c=1;
cout<<"First five multiples of "<<n<<" are : ";
while(a%n!=0 && a<=376020) //finding first mutiple of n after 3168.
{
a++;
}
while(c<6)//printing multiples.
{
cout<<a<<" ";
a+=n;
c++;
}
cout<<endl;
}
int main() {
int t,n;
cin>>t;//How many times you want to check.
while(t--)
{
cin>>n;
printmultiples(n);//function call..
}
return 0;
}
Input:-
3
15
43
273
Output:-
First five multiples of 15 are : 3180 3195 3210 3225 3240
First five multiples of 43 are : 3182 3225 3268 3311 3354
First five multiples of 273 are : 3276 3549 3822 4095 4368
Step-by-step explanation:
I have used a function to find the first five multiples of the of the numbers.The program can find the first five multiples of any integer between 3168 and 376020.In the function I have used while loop.First while loop is to find the first multiple of the integer n passed as an argument in the function.Then the next loop prints the first five multiples by just adding n to the first multiple.
In the main function t is for the number of times you want to print the multiples.In our case it is 3 Then input the integers whose multiples you want to find.