Okay, so I need to have the output look like a diamond of asterisks, with each row increasing by 2 asterisks until the middle has 9 asterisks...and then the rows decrease. function main has to be:
int main (void){
int i;
i = 0;
while (i < 5){
printline (4-i, i*2+1);
i = i + 1;
}
i = 3;
while (i >= 0) {
printline (4-i, i*2+1);
i = i - 1;
}
return 0;
}
Now I am supposed to define function printline to print a single line of the figure each time it is called. It takes 2 arguments, the number of spaces and the number of asterisks that should be printed on the line. Use counter controlled repetition to print the appropriate number of spaces and again to print the appropriate number of asterisks.
char print_line (int spaces, int stars){
for (int i = 4; i>=spaces; i--){
printf(" ");
}
for (int i = 1; i<=stars; i+=2){
printf("*");
}
printf("\n");
}
Woohoo! I'm almost done! The outputs kinda right, except that instead of a line with 4 spaces with a star, a line with 3 spaces with 3 stars, and so on up to no spaces and 9 stars, (and then reverses)...I get a line with a star, a line with a space and 2 stars, a line with two spaces three stars, etc, up to 4 spaces five stars (and then reverses)...
The reason printline is different is because I have problems writing with this sometimes and I kept on getting italics whenever I tried to write it...