Friday, July 22, 2011

Program to print numbers in Traingular pattern {Type 15}


1                                     1
1  2                             2 1
1  2  3                    3  2  1
1  2  3  4           4  3  2  1
1  2  3  4  5  5  4   3  2  1
1  2  3  4           4  3  2  1
1  2  3                    3  2  1
1  2                             2 1
1                                     1

==========================================================
/*Serial No.40     [swami11.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l=1,m=1,n;
clrscr();
printf("Enter the last number==>");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
for(k=1;k<=2*n-1-l;k++)
printf(" ");
for(j=i;j>=1;j--)
printf("%d",j);
l=l+2;
printf("\n");
}
for(i=1;i<=n-1;i++)
{
for(j=1;j<=n-i;j++)
printf("%d",j);
for(k=1;k<=m+1;k++)
printf(" ");
for(j=n-i;j>=1;j--)
printf("%d",j);
m=m+2;
printf("\n");
}
getch();
}

1 comment:

  1. If you are searching for a program not listed here or need help in completing the program then you can discuss it here....using comment or mail......I will make sure your work gets done...

    ReplyDelete

If you have any doubt, feel free to ask...