You are on page 1of 10

#include<stdio.

h>]
#include<conio.h>
void main ()
{
int i,j,n;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
/*OUTPUT
enter no of rows7
*
**
***
****
*****
******
*******
*/

#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%6d",j);
}
printf("\n\n");
}
getch();
}
/*enter no of rows8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
*/
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,k;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=1;i<=n;i++)
{ k=i;
for(j=1;j<=i;j++)
{
printf("%5d",k--);
}
printf("\n");
}
getch();
}
/*OUTPUT
enter no of rows5
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
*/

#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,k=0;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{ k=k+1;
printf("%6d",k);
}
printf("\n\n");
}
getch();
}
/* output
enter no of rows6
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21 */
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,k;
clrscr();
printf("enter no of rows");
scanf("%d",&m);
for(n=1;n<=m;n++)
{
for(k=1;k<=n;k++)
{
printf("%d",k);
}
printf("\n");
}
for(i=m-1;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
/*
enter no of rows12
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
1234567891011
123456789101112
1234567891011
12345678910
123456789
12345678
1234567
123456
12345
1234
123
12
1
*/#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,k=0;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
for(j=n;j>=i;j--)
{printf("%d",j);
}
printf("\n");
}
getch();
}
/* output
enter no of rows6
6
65
654
6543
65432
654321
*/
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,k=0;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
for(j=n;j>=i;j--)
{printf("%2d",j);
}
printf("\n");
}
getch();
}
/* output
enter no of rows6
6
6 5
6 5 4
6 5 4 3
6 5 4 3 2
6 5 4 3 2 1
*/#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
m=n+1-i;
for(j=1;j<=m;j++)
{printf("%d",j);
}
printf("\n");
}
getch();
}
/* output
enter no of rows7
1
12
123
1234
12345
123456
1234567
*/
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
m=n+1-i;
for(j=1;j<=m;j++)
{printf("%2d",j);
}
printf("\n");
}
getch();
}
/* output
enter no of rows8
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 #include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,r;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i-1;j++)
{
printf(" ");
}
m=n+1-i;
for(j=1;j<=m;j++)
{printf("%d",j);
}
for(r=m-1;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
getch();
}
/* output
enter no of rows8
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,r;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(j=1;j<=n+1-i;j++)
{printf("%d",j);
}
for(r=n-i;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
getch();
}
/* output
enter no of rows6
12345654321
123454321
1234321
12321
121
1
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,r,k;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(k=1;k<=2*n-2*i;k++)
{printf(" ");
}
for(r=i;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
getch();
}
/* output
enter no of rows6
1 1
12 21
123 321
1234 4321
12345 54321
123456654321
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,r,k;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(k=2*n-2*i;k>=1;k--)
{printf(" ");
}
for(r=i;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
getch();
}
/* output
enter no of rows5
1234554321
1234 4321
123 321
12 21
1 1
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,j,n,m,r,k;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(k=2*n-2*i;k>=1;k--)
{printf(" ");
}
for(r=i;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(k=1;k<=2*n-2*i;k++)
{printf(" ");
}
for(r=i;r>=1;r--)
{
printf("%d",r);
}
printf("\n");
}
getch();
}
/* output
eenter no of rows8
1234567887654321
1234567 7654321
123456 654321
12345 54321
1234 4321
123 321
12 21
1 1
1 1
12 21
123 321
1234 4321
12345 54321
123456 654321
1234567 7654321
1234567887654321

#include<stdio.h>
#include<conio.h>
void main ()
{
int n,a,j,k,p=1,m;
clrscr();
printf("enter no of rows");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
for(j=1;j<=n-a;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{if(p>9)
p=0;
printf("%d",p);
m=p;
p++;
}
for(k=a-1;k>0;k--)
{
if(m==0)
m=10;
printf("%d",--m);
p=m+1;
}
printf("\n");
}
getch();
}
/* output
enter no of rows10
1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
0123456789876543210

You might also like