Link Search Menu Expand Document

Challenge 3 - Print a Right-Angled Triangle

Problem Statement

  • Write a code which prints a right-angled triangle of the character &.

The code takes an integer variable row as input and prints the right-angled triangle with that number of rows displaying &.

The base of the right-angled triangle is the input number, i.e., input of n will yield a triangle of base n

Input

 positive integer
 

Output

 right-angled triangle
 

Sample Input

   5

Sample Output

   &
   &&
   &&&
   &&&&
   &&&&&
   

Coding Exercise

fn test(n:i32) {
 // Write code here!
}

Good luck! 🤞