Social Icons

Friday, 21 March 2014

Pattern of numbers(digits)

#include<stdio.h>
#include<conio.h>
main()
{
int n, c, d, num = 1, space;
clrscr();
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");
}
}

                                                                                                    also see codes of following-
                                                                                                    Floyd triangle
                                                                                                    Pascal triangle

                                           OUTPUT

No comments:

Post a Comment