Create file called stars2.c
and paste the contents of stars.c
from Class 16 into it.
Compile and run the program to make sure it works. Then modify the the code so that the part that prints the stars uses for
loops instead of while
loops (the part from line 18 to the end).
Submit your program to me on Slack. If you don't finish today, it is due by the end of next class (11/16/2017).
Copy the contents of either stars.c
from Class 16, or stars2.c
into a file called stars3.c
. You can choose either one of them depending on your preference for while
loops or for
loops.
Modify the program in stars3.c
to print a number of rows equal to the user input, but instead of increasing the number of stars
by one for each row, increase them by two. So the output will look like:
Enter an integer: 5
*
***
*****
*******
*********
Then modify stars3.c
so that it prints the stars in this arrangement:
Enter an integer: 5
*
***
*****
*******
*********
Then modify stars3.c
so that it prints a tree shape:
Enter an integer: 5
*
***
*****
*******
*********
***
***
Note that the row count is still the size of the triangle part (the trunk is added on).
Also, the size of the trunk should be scaled somehow to the row count. For example:
Enter an integer: 7
*
***
*****
*******
*********
***********
*************
*****
*****
*****