Search C Program

Number Pattern - 32

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1


#include<stdio.h>
int main()
{
  int i,j;
  for(i=1;i<=4;i++)
  {
    for(j=1;j<=i;j++)
    {
      if(j<i) 
        printf("%d*",i);
      else 
        printf("%d",i);
    }
    printf(" \n");
  }
  for(i=4;i>=1;i--)
  {
    for(j=1;j<=i;j++)
    {
      if(j<i) 
        printf("%d*",i);
      else 
        printf("%d",i);
    }
    printf(" \n");
  }  
  return 0;
}


Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C


2 comments:

  1. following is the small modification of above program
    for(i=1;i<=4;i++)
    {
    for(j=1;j<=i;j++)
    {
    if(j!=1)
    printf("%d*",i);
    else
    printf("%d",i);
    }
    printf(" \n");
    }

    ReplyDelete
  2. #include

    int main()
    {
    int r,i,j;

    printf("Enter the no. of rows : ");
    scanf("%d",&r);

    for(i=1;i<=r;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",i);

    if(j!=i)
    {
    printf("*");
    }
    }

    printf("\n");
    }

    for(i=r;i>=1;i--)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d",i);

    if(j!=i)
    {
    printf("*");
    }
    }

    printf("\n");
    }

    return 0;
    }

    ReplyDelete