Hello. I am in a beginner C++ programming class. This is my first class I have ever done any programming in my whole life. I'll also mention that though it's a college freshman class, there are many parts to the programs that we have to write that I just do not understand. The current project that I am working on involves printing 4 different patterns to the screen(like the ones I have provided below)
1st
*
**
***
****
*****
2nd
*********
********
*******
******
*****
****
***
**
*
3rd: like 1 but w/ setw(9)
4th: like 2 but w/ setw(9)
I can get the 2nd one to work with the following program:
-
int(main)
-
{
-
int i, j, k;
-
-
for(i=1; i<=20; i++)
-
-
{
-
-
cout<<"\n";
-
-
for(j=i; j<=20; j++)
-
{
-
cout<< '*';
-
}
-
}
-
cout << endl;
but I am not sure how to go about getting the others to work, for what I have tried has given me infinite asterisks. Below is what I have tried.
-
for(k=i; k<=20; k--)
-
{
-
cout << " ";
-
cout << setw(9) << fixed << '*';
-
}
Any help, hints, or suggestions would be GREATLY appreciated.
Thanks,
Amber