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