Previous Next
0 / 18
Module DEMO-32-91DEMO-C-32

Rectangle Pattern of Carets

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Write a program that reads two integers representing the dimensions of a rectangle (rows and columns) and prints a rectangle made of carets (^) separated by spaces. Each row should contain exactly the specified number of columns, with each caret separated by a single space. The rectangle should have exactly the specified number of rows.

Constraints

0 ≤ R ≤ 100 0 ≤ C ≤ 100

Input Format

The input consists of two integers on a single line separated by a space: the number of rows (R) and the number of columns (C).

Output Format

The output should consist of R lines, each containing exactly C carets (^) separated by single spaces. There should be no trailing spaces on any line.

Sample Testcases

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

Sample #1
Public sample
2 3
^ ^ ^
^ ^ ^
Basic rectangle with 2 rows and 3 columns
Sample #2
Public sample
0 3
Zero rows should produce no output
Sample #3
Public sample
5 0
Zero columns should produce 5 empty lines
Sample #4
Public sample
3 0
Three rows with zero columns
Sample #5
Public sample
7 1
^
^
^
^
^
^
^
Seven rows with single column

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