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