write a java program to print the following pattern..
1
23
345
4567
56789
Answers
Answered by
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
English,
3 months ago
Social Sciences,
3 months ago
Math,
8 months ago
Economy,
8 months ago
Social Sciences,
1 year ago