Advertisement
dmilicev

asterisks v1.c

Oct 2nd, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. /*
  2. asterisks v1.c
  3.  
  4. C program to print following:
  5.  
  6. * * * * *
  7. *
  8. * * * *
  9. * *
  10. * * *
  11. * * *
  12. * *
  13. * * * *
  14. *
  15. * * * * *
  16.  
  17. Image analysis concludes the following:
  18.  
  19. If the row is odd,  we show 5, 4, 3, 2, 1 asterisks in a row.
  20. If the row is even, we show 1, 2, 3, 4, 5 asterisks in a row.
  21.  
  22. We print two lines at a time.
  23. In the first line 5 stars and in the second line 1 stars.
  24. We then reduce the number of stars for the first line
  25. and increase the number of stars for the second line.
  26. Repeat this 5 times for 10 rows.
  27. */
  28.  
  29. #include<stdio.h>
  30.  
  31. int main()
  32. {
  33.     int i,row,times,FirstCounter=5,SecondCounter=1;
  34.  
  35.     printf("\n");
  36.  
  37.     for(times=0; times<5; times++)
  38.     {
  39.         for(i=0; i<FirstCounter; i++)
  40.             printf("* ");
  41.  
  42.         FirstCounter--;
  43.         printf("\n\n");
  44.  
  45.         for(i=0; i<SecondCounter; i++)
  46.             printf("* ");
  47.  
  48.         SecondCounter++;
  49.         printf("\n\n");
  50.     }
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement