Pages

Thursday, 17 September 2015

Print a number pattern without using second loop

Number pattern without using second loop

Coding:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
    char s[30]="",s1[30]="1";
    unsigned long int j,i;
    int n;
    printf("Please enter total Number of Line:");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        strcat(s,s1);
        j=atoi(s)*i;
    printf("%lu\n",j);
    }
  
}
Output:
Please enter total Number of Line:8
1
22
333
4444
55555
666666
7777777
88888888