Advertisement
Mr_kindle

Starpattern.c

Oct 31st, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. /*Print following pattern
  2. *
  3. ***
  4. *
  5. ***
  6. ***
  7. *
  8. ***
  9. ***
  10. ***
  11. *
  12. ***
  13. ***
  14. ***
  15. ***
  16. */
  17.  
  18.  
  19. #include<stdio.h>
  20.  
  21. int main()
  22. {
  23.     int n,i,m=1,j,k;
  24.    printf("please enter the number of lines:\n");
  25.    scanf("%d",&n);
  26.     for (i=1;i<=n;i++)
  27.     {    printf("* ");
  28.         printf("\n");
  29.         k=m;
  30.         while(k)
  31.         {  if(i==n)
  32.              break;
  33.            i++;
  34.        
  35.         for(j=1;j<=3;j++)
  36.         {    printf("* ");
  37.         }
  38.         printf("\n");
  39.         k--;
  40.         }
  41.         m++;
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement