In this program, the pattern as shown below will be displayed.
1 2
3
4 5
6
7 8
9
10 11
The upper range of the pattern ( as per the above pattern it is 11) will be given by user.
#include< stdio.h>
void main()
{
int i=1,j,n,x=1;
clrscr();
printf("\nEnter the Last Number of the series:");
scanf("%d",&n);
for(;;)
{
for(j=0;j<=i;j++)
{
printf(" %d",x);
x++;
}
if(i==1)
i=0;
else
i=1;
if(x >n)
break;
printf("\n");
}
getch();
}
No comments:
Post a Comment