Previous Next
0 / 33
Module DEMO-32-60DEMO-C-32

Inverted Right-Angled Triangle

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program that reads an integer N and prints an inverted right-angled triangle made of asterisks (*).

Pattern Details

  • The first row should contain N asterisks.
  • Each subsequent row should have one fewer asterisk than the previous.
  • The last row should contain exactly one asterisk.

This pattern is best implemented using nested loops.

Constraints

Use nested loops to generate the pattern.

Input Format

A single integer N where 1 <= N <= 20.

Output Format

An inverted right-angled triangle of asterisks with N rows.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3
***
**
*
Input: 3
Sample #2
Public sample
5
*****
****
***
**
*
Input: 5
Sample #3
Public sample
2
**
*
Input: 2

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings