C Program to Print Consecutive Row Numbers in Right Triangle

Write a C program to print consecutive row numbers in right triangle pattern using for loop.

#include <stdio.h>

int main()
{
    int i, j, rows, val;
    
    printf("Enter Right Triangle Consecutive Row Nums Pattern Rows = ");
    scanf("%d",&rows);

    printf("\nThe Consecutive Numbers in Right Triangle Row Pattern\n"); 
    
	for (i = 1; i <= rows; i++ ) 
	{
		val = i;
		for (j = 1 ; j <= i; j++ ) 	
		{
			printf("%d ", val);
			val = val + rows - j;
		}
		printf("\n");
	}

    return 0;
}
C Program to Print Consecutive Row Numbers in Right Triangle

This C example prints the right angled triangle pattern of consecutive row numbers using a while loop.

#include <stdio.h>

int main()
{
    int i = 1, j, rows, val;
    
    printf("Enter Right Triangle Consecutive Row Nums Pattern Rows = ");
    scanf("%d",&rows);

    printf("\nThe Consecutive Numbers in Right Triangle Row Pattern\n"); 
    
	while(i <= rows ) 
	{
		val = i;
		j = 1 ;
		while ( j <= i) 	
		{
			printf("%d ", val);
			val = val + rows - j;
			j++ ;
		}
		printf("\n");
		i++;
	}

    return 0;
}
Enter Right Triangle Consecutive Row Nums Pattern Rows = 12

The Consecutive Numbers in Right Triangle Row Pattern
1 
2 13 
3 14 24 
4 15 25 34 
5 16 26 35 43 
6 17 27 36 44 51 
7 18 28 37 45 52 58 
8 19 29 38 46 53 59 64 
9 20 30 39 47 54 60 65 69 
10 21 31 40 48 55 61 66 70 73 
11 22 32 41 49 56 62 67 71 74 76 
12 23 33 42 50 57 63 68 72 75 77 78 

C Program to display consecutive row numbers in the right angled triangle using a do while loop.

#include <stdio.h>

int main()
{
    int i = 1, j, rows, val;
    
    printf("Enter Right Triangle Consecutive Row Nums Pattern Rows = ");
    scanf("%d",&rows);

    printf("\nThe Consecutive Numbers in Right Triangle Row Pattern\n"); 
    
	do 
	{
		val = i;
		j = 1 ;
		do	
		{
			printf("%d ", val);
			val = val + rows - j;

		} while ( ++j <= i);
		printf("\n");

	} while(++i <= rows );

    return 0;
}
Enter Right Triangle Consecutive Row Nums Pattern Rows = 14

The Consecutive Numbers in Right Triangle Row Pattern
1 
2 15 
3 16 28 
4 17 29 40 
5 18 30 41 51 
6 19 31 42 52 61 
7 20 32 43 53 62 70 
8 21 33 44 54 63 71 78 
9 22 34 45 55 64 72 79 85 
10 23 35 46 56 65 73 80 86 91 
11 24 36 47 57 66 74 81 87 92 96 
12 25 37 48 58 67 75 82 88 93 97 100 
13 26 38 49 59 68 76 83 89 94 98 101 103 
14 27 39 50 60 69 77 84 90 95 99 102 104 105