Program to display a pattern like a right angle triangle using an asterisk.

*

**

***

****

*****

Here, we have a basic program example to print a right angled triangle using different languages. This program is created in c language, c++, Java, and Python.

Code to print right angled triangle in C language

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

Code to print right angled triangle in C++ language

#include <iostream>
using namespace std;
int main() {
    int i,j,rows;
 cout<<"Input number of rows : ";
 cin>>rows;
   for(i=1;i<=rows;i++)
   {
	for(j=1;j<=i;j++)
	   cout<<"*";
       cout<<"\n";
   }
}

Code to print right angled triangle in Python language

rows = int(input("Input number of rows : "))
for i in range (1, rows+1):
   for j in range (1, i+1):
      print("*" , end='')
   print()

Code to print right angled triangle in Java language

import java.util.*;
public class pattern {
    public static void main(String[] args) {     
        int i,j,rows;
       
	System.out.println("Enter a positive integer:  ");
        Scanner s=new Scanner(System.in);
        rows = s.nextInt();

      for(i=1;i<=rows;i++)
         {
	for(j=1;j<=i;j++)
	   System.out.print("*");
	System.out.print("\n");
         }
      }
}