> C Programming Help... Please?

C Programming Help... Please?

Posted at: 2014-12-18 
Use this basic outline (add some C code to flesh it out):

1. Input number of stars (call it NumStars)

2. Loop i for 1 to NumStars

3. Print i number of stars (you can use another loop here for j=1 to i)

4. Repeat loop

5. Loop i from NumStars down to 1

6. Print i number of stars (you can use another loop here for j=1 to i)

7. Repeat loop

That should help. Good luck.

N

#include

int main()

{

int maxNumberOfStars, i, j, flag = 0;



printf("Please enter the maximum number of stars: ");

scanf("%d", &maxNumberOfStars);



for(i = 0; i < (2 * maxNumberOfStars); i++)

{

if(i == maxNumberOfStars)

flag = 1;



if(!flag)

{

for(j = 0; j <= i; j++)

printf("*");

}

else

{

for(j = (2 * maxNumberOfStars) - i; j > 0; j--)

printf("*");

}



printf("\n");

}



return 0;

}

I have an assignment due and I really need some help... Please and thank you!!

You are asked to input a number between 1 and 10. Using just for loops, output a series of stars starting with one star on a line and then incrementing the number of stars on the line until the line contains the number of stars entered. Then decreasing the number of stars per line until only a single star is on the output line.



Example:

Please enter the maximum number of stars.

5

*

**

***

****

*****

*****

****

***

**

*