Pages

Sunday, 14 June 2015

Number pattern 12

Number pattern 12

Coding:

#include<stdio.h>
int main()
{
int i,j,n,f=0;
printf("Please enter number of lines:");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
f=0;
for(j=i;j>=1;j--)
{
if(f==0)
{
printf("%d",i);
f=1;
}
else
{
printf("%d",i-1);
f=0;
}
}
printf("\n");
}
return 0;
}

Output:
Please enter number of lines:5
54545
4343
323
21
1