Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- asterisks v1.c
- C program to print following:
- * * * * *
- *
- * * * *
- * *
- * * *
- * * *
- * *
- * * * *
- *
- * * * * *
- Image analysis concludes the following:
- If the row is odd, we show 5, 4, 3, 2, 1 asterisks in a row.
- If the row is even, we show 1, 2, 3, 4, 5 asterisks in a row.
- We print two lines at a time.
- In the first line 5 stars and in the second line 1 stars.
- We then reduce the number of stars for the first line
- and increase the number of stars for the second line.
- Repeat this 5 times for 10 rows.
- */
- #include<stdio.h>
- int main()
- {
- int i,row,times,FirstCounter=5,SecondCounter=1;
- printf("\n");
- for(times=0; times<5; times++)
- {
- for(i=0; i<FirstCounter; i++)
- printf("* ");
- FirstCounter--;
- printf("\n\n");
- for(i=0; i<SecondCounter; i++)
- printf("* ");
- SecondCounter++;
- printf("\n\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement