In this tutorial, we will learn how to print odd number patterns in C. Before that, you may go through the following topic in C.
The program takes a user input for the number of rows and prints the number pattern of the pyramid for odd numbers in C.
C Program to print Odd Number Pattern
#include <stdio.h>
void main()
{
int i, j, k = 1, rows;
printf("Enter the no. of rows: ");
scanf("%d", &rows);
for (i = 1; i <= rows; i++)
{
for (j = 1; j <= i; j++)
{
printf("%2d ", k);
k = k + 2;
}
printf("\n");
}
getch();
}
Output:
