C Online Compiler
Example: C Program to Print Half Pyramid Pattern of Numbers
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Print Half Pyramid Pattern of Numbers #include <stdio.h> int main() { int rows; printf("Enter the number of rows: "); scanf("%d", &rows); if (rows > 0) { for (int i = 1; i <= rows; i++) { for (int j = 1; j <= i; j++) { printf("%d ", j); } printf("\n"); } } return 0; }
5
Output
Clear
ADVERTISEMENTS