Pattern Printing Programs in C and Python — Pyramid & String
Classified in Computers
Written on in
English with a size of 4.26 KB
Number Pyramid of Integers
Write a program to generate the following patterns of integers:
1
121
12321
1234321Corrected C Program (Number Pyramid)
The following C program prints the above centered palindrome number pyramid. It prompts for the number of rows.
#include <stdio.h>
int main()
{
int i, j, row;
printf("Enter number of rows: ");
if (scanf("%d", &row) != 1) {
printf("Invalid input.\n");
return 1;
}
for (i = 1; i <= row; i++)
{
for (j = 1; j <= row - i; j++)
{
printf(" ");
}
for (j = 1; j <= i; j++)
{
printf("%d", j);
}
for (j = i - 1; j >= 1; j--)... Continue reading "Pattern Printing Programs in C and Python — Pyramid & String" »