Write a program to print the following pattern
1
12
123
1234
12345
1234
123
12
1
#include<stdio.h>
main()
{
int i,j,n,k;
printf("Enter the number:");
scanf("%d",&n);
for(i=1;i<n;i++)
{
for(k=1;k<=i;k++)
printf("%d",k);
printf("\n");
}
for(i=n;i>=0;i--)
{
for(k=1;k<=i;k++)
printf("%d",k);
printf("\n");
}
}
1
12
123
1234
12345
1234
123
12
1
#include<stdio.h>
main()
{
int i,j,n,k;
printf("Enter the number:");
scanf("%d",&n);
for(i=1;i<n;i++)
{
for(k=1;k<=i;k++)
printf("%d",k);
printf("\n");
}
for(i=n;i>=0;i--)
{
for(k=1;k<=i;k++)
printf("%d",k);
printf("\n");
}
}
No comments:
Post a Comment