C Programming
Computer Programming

Program in C to display the number pattern



Write a Program in c to display the following Pattern :


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

\* C Program to display the number pattern *\

# include < stdio.h >
int   main( )
{

int   i, j, n, k = 1 ;
printf(" Enter the Maximum Number : ") ;
scanf("%d ", & n) ;
printf("\n Pattern are : \n\n") ;
for (  i = 1 ; i < = n ; i++ )
{

for (  j = 1 ; j < = ( 2 * i )-1 ; j++ )
{

if (j % 2 == 0 )
printf("   *   ") ;
else
printf("   %d " ,  i) ;

}
printf(" \n ") ;

}
for (  i = n ; i >= 1 ; i-- )
{

for (  j = ( 2 * i ) - 1 ; j >= 1 ; j-- )
{

if (j % 2 == 0 )
printf("   *   ") ;
else
printf("   %d " ,  i) ;

}
printf(" \n ") ;

}
return ( 0 );

}

Output of Program :