Write a function to construct the image shown below.
1
13
135
1357
135
13
1
#include <stdio.h>
#include <conio.h>
void degfun ( int );
void main ( )
{
int n;
clrscr ( );
printf("\n\n\n\t Enter the number of rows..:"); scanf("%d",&n);
printf("\n\n\n");
degfun ( n );
getch ( );
}
void degfun ( int n )
{
int i, j, s;
for ( i = 1; i <= n; i = i+2 )
{
printf("\t\t\t");
for ( s = n; s >= i; s = s - 2 )
{
printf(" ");
}
for ( j = 1; j <= i; j = j + 2 )
{
printf("%d", j );
}
printf("\n\n");
}
for ( i = n - 2; i >= 1; i = i - 2 )
{
printf("\t\t\t");
for ( s = n; s >= i; s = s - 2 )
{
printf(" ");
}
for ( j = 1; j <= i; j = j + 2 )
{
printf("%d",j);
}
printf("\n\n");
}
}
Click here to contact us
1
13
135
1357
135
13
1
#include <stdio.h>
#include <conio.h>
void degfun ( int );
void main ( )
{
int n;
clrscr ( );
printf("\n\n\n\t Enter the number of rows..:"); scanf("%d",&n);
printf("\n\n\n");
degfun ( n );
getch ( );
}
void degfun ( int n )
{
int i, j, s;
for ( i = 1; i <= n; i = i+2 )
{
printf("\t\t\t");
for ( s = n; s >= i; s = s - 2 )
{
printf(" ");
}
for ( j = 1; j <= i; j = j + 2 )
{
printf("%d", j );
}
printf("\n\n");
}
for ( i = n - 2; i >= 1; i = i - 2 )
{
printf("\t\t\t");
for ( s = n; s >= i; s = s - 2 )
{
printf(" ");
}
for ( j = 1; j <= i; j = j + 2 )
{
printf("%d",j);
}
printf("\n\n");
}
}
Click here to contact us
No comments:
Post a Comment