To print the given pyramid pattern in C, you can use nested loops. The outer loop controls the rows, and the inner loop controls the numbers to be printed in each row. Here's a simple C program to achieve this:
#include <stdio.h>
int main() {
int rows = 5;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf("%d", j);
}
for (int j = i - 1; j >= 1; j--) {
printf("%d", j);
}
printf("\n");
}
return 0;
}
This program will output the desired pyramid pattern.
#include <iostream> int main() { std::cout << "1 121 12321 1234321" << std::endl; return 0; }
21 The pattern is 121, 12321, 1234321
121, 484, 12321, 1234321, 123454321, 12345654321, 1234567654321, 123456787654321, 1234567897654321, 1002001, 10201, 100020001, 10000200001, 1000002000001
It is: 12321/1000 = 12.321 kg
151807041
#include <iostream> int main() { std::cout << "1 121 12321 1234321" << std::endl; return 0; }
21 The pattern is 121, 12321, 1234321
121, 484, 12321, 1234321, 123454321, 12345654321, 1234567654321, 123456787654321, 1234567897654321, 1002001, 10201, 100020001, 10000200001, 1000002000001
12321 = 12,321
It is: 12321/1000 = 12.321 kg
9, 1369 and 12321
Just as 12321 is a palindrome, .12321 is, also. 123.321 is also palindromic.
/*determine the pattern 1234321*/ #include<stdio.h> #include<conio.h> main() { int i, j; for (i=1; i<=7; i++) { if (i<5) { j=i; printf("\n %d", j); } else { j=8-i; printf("\n %d", j); } } getch() }
12321
12321.
151807041
Yes.