Computer Science, asked by abhay25102004, 8 months ago

write a java program to print the following pattern..
1
23
345
4567
56789

Answers

Answered by ChromaticSoul
30

Program:

/**

* C program to print number pattern

*/

#include <stdio.h>

int main()

{

int i, j, k, N;

printf("Enter N: ");

scanf("%d", &N);

for(i=1; i<=N; i++)

{

k = i;

// Logic to print spaces

for(j=i; j<N; j++)

{

printf(" ");

}

// Logic to print numbers

for(j=1; j<=i; j++, k++)

{

printf("%d", k);

}

printf("\n");

}

return 0;

}

Output:

1

23

345

4567

56789

Similar questions