C Programming

Solved Example

Practice Questions

Exercise Question

Print the right triangle pattern

Objective

Write a c program to print the right triangle for the specified number of rows as shown below...

*
**
***
****
*****
******
*******
********
*********
**********

C Program

#include "stdio.h"
int main() {
	int i,j,n;
	printf("Enter the number of rows: ");
	scanf("%d",&n);
	
	for(i = 1; i <= n; i++) {
		for(j = 1;j <= i; j++) {
			printf("*");
		}
		printf("\n");
	}
	
	return 0;
}

Output

Enter the number of rows: 10
*
**
***
****
*****
******
*******
********
*********
**********