Left-Shifted Odd Number Triangle in C

Beginner
⏱️ 6 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Step Increments

What You’ll Learn

How to print a left-shifted odd number triangle in C. Each new row starts from the next odd number but continues printing consecutive odd numbers to the end.

This pattern is a great way to practice step increments like i += 2 and j += 2.

⭐ Pattern Output

With odd numbers from 1 to 9, the output looks like this:

Output
13579
3579
579
79
9
1

Complete C Program

The outer loop sets the starting odd number for each row and the inner loop prints odd numbers up to 9.

c
#include <stdio.h>

int main() {
    int i, j;

    for (i = 1; i <= 10; i += 2) {
        for (j = i; j <= 10; j += 2) {
            printf("%d", j);
        }
        printf("\n");
    }

    return 0;
}
2

Variation — User Input Version

Accept the maximum value from the user (odd numbers will be printed up to that max):

c
#include <stdio.h>

int main() {
    int max;
    int i, j;

    printf("Enter the maximum value: ");
    scanf("%d", &max);

    for (i = 1; i <= max; i += 2) {
        for (j = i; j <= max; j += 2) {
            printf("%d", j);
        }
        printf("\n");
    }

    return 0;
}

Explore More Number Patterns

Try changing the starting value or step size to create even-number and prime-number triangles.

All Number Patterns →
Did you know?

Using += 2 is a simple and efficient way to iterate only odd numbers without any if condition checks inside the loop.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful