I have to create a program using a for loop that will count by 3 from the given number from the user 20 times. So far this is what i have.
#include <iostream>
using namespace std;
int main(){
int num, newNum, add;
cout << "Enter a number: ";
cin >> num;
for(int count = 0; count < 20; count++){
for(int sum = 0; sum <= count; sum++){
newNum = num * (count +1);
}
cout << num << " ";
}
}
I have no idea where to go from here. I know that i would have to put the number given into a variable like i do with num
and i know i would somehow have to store the new number in another variable like i do with newNum
. Any help would be appreciated! Also this is what the output should look like in case i did not explain it good enough.
Enter a number: 3
3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60.
And bonus points if you can have the last number end with a period instead of a comma :)