/* C program to print the given number pattern 121
1
121
12321
1234321
123454321
*/
#include <stdio.h>
#include<conio.h>
void main()
{
int i, j, N;
printf("Enter rows: ");
scanf("%d", &N);
for(i=1; i<=N; i++)
{
// Prints the first part of the pattern
for(j=1; j<=i; j++)
{
printf("%d", j);
}
// Prints the second part of the pattern
for(j=i-1; j>=1; j--)
{
printf("%d", j);
}
printf("\n");
}
getch();
}
source:codeforwin.org
1
121
12321
1234321
123454321
*/
#include <stdio.h>
#include<conio.h>
void main()
{
int i, j, N;
printf("Enter rows: ");
scanf("%d", &N);
for(i=1; i<=N; i++)
{
// Prints the first part of the pattern
for(j=1; j<=i; j++)
{
printf("%d", j);
}
// Prints the second part of the pattern
for(j=i-1; j>=1; j--)
{
printf("%d", j);
}
printf("\n");
}
getch();
}
source:codeforwin.org
No comments:
Post a Comment