Showing posts with label Print no/stars in Specific pattern. Show all posts
Showing posts with label Print no/stars in Specific pattern. Show all posts

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();
}

Program to print numbers in Traingular pattern {Type 14}


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
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
=======================================================

/*Serial No.41     [swami12.cpp]*/

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

Program to print numbers in Traingular pattern {Type 13}


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

==========================================================
/*Serial No.51     [swami23.cpp]*/

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

Program to print numbers in Traingular pattern {Type 12}


1
2  2
3  3  3
4  4  4  4
5  5  5  5  5
=====================================================
/*Serial No.4     [swami36.cpp]*/

#include<stdio.h>
#include<conio.h>
int main()
{clrscr();
int n,i,j,k=1;
printf("Enter values of n=") ;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",k);
printf("\n");
k++;
}
getch();
}

Program to print Parkside's Traingle

PARKSIDE'S TRAINGLE
1
2  3
4  5  6
7  8  9  10
.....................
================================================ 
/*Serial No.3     [swami35.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int count,j,i,m,n;
clrscr();
printf("enter the no. of lines u want to print=");
scanf("%d",&m);
printf("enter the starting value=");
scanf("%d",&n);
count =n;
i=1;
for(i=1;i<=m;i++)
{
printf("\n");
for(j=1;j<=i;j++)
{
printf("%d",count);
count++;
if(count>=32764)
break;
}
}
getch();
}

Program to print numbers in Traingular pattern {Type 11}


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

===========================================================
/*Serial No.34     [swami154.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=(n-1);k>=i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{printf(" %d",j);}
printf("\n");
}
for(i=(n-1);i>=1;i--)
{
for(k=(n-1);k>=i;k--)
{printf(" ");}
for(j=1;j<=i;j++)
{printf(" %d",j);}
printf("\n");
}
getch();
}

Program to print numbers in Traingular pattern {Type 10}


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

============================================================
/*Serial No.33     [swami153.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(k=(n-1);k>=i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{printf(" %d",j);}
printf("\n");
}
getch();
}

Program to print numbers in Traingular pattern {Type 1} {Version 2}


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

=============================================================
/*Serial No.32     [swami152.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the no.:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{printf("%d",j);}
printf("\n");}
getch();
}

Program to print numbers in Traingular pattern {Type 9}


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

============================================================
/*Serial No.31     [swami151.cpp]*/

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

Program to print numbers in Traingular pattern {Type 8}


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

-------------------------------------------------------------------------------------------
/*Serial No.30     [swami150.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(k=(n-1);k>=i;k--)
{printf(" ");}
for(j=1;j<=i;j++)
{printf("%d",j);
}
printf("\n");}
getch();
}

Program to print stars in Traingular pattern {Type 7}


            *
         *   *
      *    *   *
   *    *   *   *
*    *    *   *   *

-------------------------------------------------------------------------------------
/*Serial No.29     [swami149.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(k=(n-1);k>=i;k--)
{printf(" ");}
for(j=1;j<=i;j++)
{printf("*");
}
printf("\n");}
getch();
}

Program to print numbers in Traingular pattern {Type 6}


1  2  3  4  5
1  2  3  4
1  2  3
1  2
----------------------------------------------------------------------------------------------------
/*Serial No.28     [swami148.cpp]*/ 

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

Program to print stars in Traingular pattern {Type 5}


*  *  *  *  *
*  *  *  *
*  *  *
*  *
*
 -----------------------------------------------------------------------------
/*Serial No.27     [swami147.cpp]*/ 

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
printf("\n");
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{printf("*");
}
printf("\n");}
getch();
}

Program to print numbers in Traingular pattern {Type 4}


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

/*Serial No.26     [swami146.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=(n-1);k>=i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{printf(" %d",j);}
printf("\n");
}
getch();
}

Program to print stars in Traingular pattern {Type 3}

            *
         *    *
      *    *    *
    *    *   *   *
 *    *    *   *   *
------------------------------------------------------------------
/*Serial No.25     [swami145.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(k=(n-1);k>=i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{printf(" *");}
printf("\n");
}
getch();
}

Program to print stars in Traingular pattern {Type 2}


*
*  *
*  *  *
*  *  *  *
*  *  *  *  *
-----------------------------------------------------------------------
/*Serial No.23     [swami144.cpp]*/

/* this program prints traingle as big as u want.*/
#include<stdio.h>
#include<conio.h>
int i,j,n;
void main()
{
clrscr();
printf("Enter the no. of lines of traingle:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{printf("*\n");
if(j==n)
break;
for(j=1;j<=i;j++)
printf("*");
}
getch();
}

Program to print numbers in Traingular pattern {Type 1}


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

----------------------------------------------------
/*Serial No.22     [swami143.cpp]*/

/* this program prints numbers in traingular fashion.(up to which no. u want)*/
#include<stdio.h>
#include<conio.h>
int i,j,n;
void main()
{
clrscr();
printf("Enter the no. upto which u want to print numbers.:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{printf("%d\n",i);
if(j==n)
break;
for(j=1;j<=i;j++)
printf("%d ",j);
}
getch();
}