PYRAMID STRUCTER
1.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
if((i+j)%2==0)
printf("1
");
else
printf("0
");
}
printf("\n");
}
getch();
}
OUTPUT:
1
0 1
1 0 1
2.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=1;
clrscr();
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf("%d
",k);
k++;
}
printf("\n");
}
getch();
}
OUTPUT:
1
2 3
4 5 6
3.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=4;i>=1;i--)
{
for(j=i;j>=1;j--)
printf("%d
",j);
printf("\n");
}
getch();
}
OUTPUT:
4 3 2 1
3 2 1
2 1
1
4.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf("*
");
printf("\n");
}
getch();
}
OUTPUT:
*
* *
* * *
* * * *
* * * * *