17.To print pattern of numbers and stars


1.

     *
    ***
   *****
  *******
*********

#include <stdio.h>

int main()
{
   int row, c, n, temp;

   printf("Enter the number of rows in pyramid of stars you wish to see ");
   scanf("%d",&n);

   temp = n;

   for ( row = 1 ; row <= n ; row++ )
   {
      for ( c = 1 ; c < temp ; c++ )
         printf(" ");

      temp--;

      for ( c = 1 ; c <= 2*row - 1 ; c++ )
         printf("*");

      printf("\n");
   }

   return 0;
}


2.
*
**
***
****
*****

#include <stdio.h>

int main()
{
    int n, c, k;

    printf("Enter number of rows\n");
    scanf("%d",&n);

    for ( c = 1 ; c <= n ; c++ )
    {
        for( k = 1 ; k <= c ; k++ )
            printf("*");

        printf("\n");
    }

    return 0;
}

3.
    *
   *A*
  *A*A*
*A*A*A*

#include<stdio.h>

main()
{
    int n, c, k, space, count = 1;

    printf("Enter number of rows\n");
    scanf("%d",&n);

    space = n;

    for ( c = 1 ; c <= n ; c++)
    {
        for( k = 1 ; k < space ; k++)
           printf(" ");

        for ( k = 1 ; k <= c ; k++)
        {
            printf("*");

            if ( c > 1 && count < c)
            {
                 printf("A");   
                 count++;
            }     
        }   

        printf("\n");
        space--;
        count = 1;
    }
    return 0;
}


4.

         1
        232
       34543
      4567654
    567898765

#include<stdio.h>

main()
{
      int n, c, d, num = 1, space;

      scanf("%d",&n);

      space = n - 1;

      for ( d = 1 ; d <= n ; d++ )
      {
          num = d;

          for ( c = 1 ; c <= space ; c++ )
              printf(" ");

          space--;

          for ( c = 1 ; c <= d ; c++ )
          {
              printf("%d", num);
              num++;
          }
          num--;
          num--;
          for ( c = 1 ; c < d ; c++)
          {
              printf("%d", num);
              num--;
          }
          printf("\n");

      }

      return 0;
}