I got the program to do 10 lines of stars and increment by 1 until 5 and then decrement by 1 from 5 to 1. Now i want to increment the star on each line by 2 and have 1 star on the first line and then 3 one the second... until the 5th where there would be 9 and then decrement by 2 going from 9 to 1 but i cant seem to figure it out. This is the code i have but it doesnt work. Help please
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main () {
int i,j;
for (i=1; i<=5; ++i) {
for (j=1; j<=i; j+=2){
cout << "*"; }
cout << "\n";
}
for (i=5; i>=1; --i) {
for (j=1; j<=i; j+=2) {
cout << "*";}
cout << endl;
}
return 0;
}