Answer to Question #166627 in C++ for Earl Davis Jr.

Question #166627

Create a program that will output the multiples of 5. It must start at 0 and show however many numbers the users asks for. In addition, the numbers should output on a new line every time a multiple of 100 is reached. 

 

Prompt:

This program will output the multiples of 5. How many numbers do you want to see?   [user types: 42]

 

Output:

0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100

105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200

205

 

Notes and Hints:

1) You can use any type of loop, but there is an obvious choice here.


1
Expert's answer
2021-02-27T11:55:41-0500
#include<iostream>
using namespace std;

int main(){
int n,i,sum=0;
cout<<"Please enter the total available number"<<endl;

cin>>n;
int scan[n];
for(i=0;i<n;i++){
cin>>scan[i];

}

for(int j=0;j<n;j++){
        sum=5*scan[j];
printf("%d,",sum);

}
printf("\n");
for(int k=0;k<n;k++){

    printf("%d,",(100+5*scan[k]));

}

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