Beginners C

#include
#include
int pyramid( int length )
{
int line = 1;
int j = 1, i, k = length;
while( length-- ) {
if( j == 1 ) {
for( i = 1; i <= length + 5; i++ )
printf( " " );
printf( "%d
", j++ );
k--;
line++;
}
else if( i % 2 ){
for( i = 1; i <= length + 5; i++ )
printf( " " );
for( i = 1; i <= line; i++ )
printf( "%d ", ( j++ % 10 ) );
printf( "
" );
line++;
k--;
}
else {
for( i = 1; i <= length + 5 ; i++ )
printf( " " );
for( i = 1; i <= line; i++ )
printf( "%d ", ( j++ % 10 ) );
printf( "
" );
line++;
k--;
}
}
return 0;
}
int main( )
{
int length;
printf( "Enter the list length
" );
scanf( "%d", &length );
pyramid( length );
getch( );
return 0;
}