i have to write a code that makes the asterisks print like this:
*
**
***
and so on. this is what i had before, but this code is wrong since my professor told me. it works, but she said that she wants something different. and i'm stuck, i have no idea how she wants to do it. this is the code i had before:
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 y;
for(int k = 0; k < 1; k++){
cout<<"*"<<endl;
for(int k = 1; k < 2; k++)
cout<<"**"<<endl;
}
for (int k = 2; k < 3; k++){
cout<<"***"<<endl;
}
cin>>y;
return 0;
}
i have to use two for loops (one nested) to that prints the asterisks i showed above.
Your going to want to cout a single char in one of the loops, and a newline in the other.
The main difficulty is figuring out the number of loops the inner most loop must do to print the correct amount of stars.