Pattern 12
write a prog. to print following pattern
1
23
456
7890
12345
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j,k;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
k=1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(k>9)
{
k=0;
}
printf("%d",k);
k++;
}
printf("\n");
}
getch();
}
O/P:
write a prog. to print following pattern
1
23
456
7890
12345
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j,k;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
k=1;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(k>9)
{
k=0;
}
printf("%d",k);
k++;
}
printf("\n");
}
getch();
}
O/P:
No comments:
Post a Comment