Advertisement
kamandos

DiamondPattern

Jul 5th, 2022
760
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None
  1. #include <stdio.h>
  2. int main()
  3. {
  4.   int n, c, k;
  5.  
  6.   printf("Enter number of rows\n");
  7.   scanf("%d", &n);
  8.  
  9.   for (k = 1; k <= n; k++)
  10.   {
  11.     for (c = 1; c <= n-k; c++)
  12.       printf(" ");
  13.  
  14.     for (c = 1; c <= 2*k-1; c++)
  15.       printf("*");
  16.  
  17.     printf("\n");
  18.   }
  19.  
  20.   for (k = 1; k <= n - 1; k++)
  21.   {
  22.     for (c = 1; c <= k; c++)
  23.       printf(" ");
  24.  
  25.     for (c = 1 ; c <= 2*(n-k)-1; c++)
  26.       printf("*");
  27.  
  28.     printf("\n");
  29.   }
  30.  
  31.   return 0;
  32. }
Advertisement
RAW Paste Data Copied
Advertisement