Advertisement
Nahid8195

Star Pattern

Oct 31st, 2022
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i, j, N, columns;
  6.  
  7.     printf("Enter number of columns:");
  8.     scanf("%d",&N);
  9.  
  10.     columns=1;
  11.  
  12.     for(i=1;i<N*2;i++)
  13.     {
  14.         for(j=1; j<=columns; j++)
  15.         {
  16.             printf("* ");
  17.         }
  18.  
  19.         if(i < N)
  20.         {
  21.             columns++;
  22.         }
  23.         else
  24.         {
  25.             columns--;
  26.         }
  27.         printf("\n");
  28.     }
  29.  
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement