In this program we will print the pattern as shown below using C programming language.
The pattern is as follows:
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5
Codes of the C program
#include
void main()
{
int i,j,x=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",x);
if(i%2==0)
x--;
else
x++;
}
if(i%2==0)
x=1;
else
x=j;
printf("\n");
}
getch();
}
Another pattern using C program
1
3
6
10
15
#include
void main()
{
int i,x=1,y=2;;
for(i=0;i<5;i++)
{
printf("%d\n",x);
x=x+y;
y++;
}
getch();
}
The pattern is as follows:
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5
Codes of the C program
#include
void main()
{
int i,j,x=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",x);
if(i%2==0)
x--;
else
x++;
}
if(i%2==0)
x=1;
else
x=j;
printf("\n");
}
getch();
}
Another pattern using C program
1
3
6
10
15
#include
void main()
{
int i,x=1,y=2;;
for(i=0;i<5;i++)
{
printf("%d\n",x);
x=x+y;
y++;
}
getch();
}
i saw some very interesting pattern programs of C language,but unable to find those here in this link..iam searching code of following patteren.
ReplyDelete1 2 3 4 5 6
1 3 5 7 9 11
1 4 7 10 13 16
1 5 9 13 17 21