C++ Online Compiler
Example: Solid Rectangle Pattern in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Solid Rectangle Pattern #include <iostream> using namespace std; int main() { int rows = 3; int cols = 5; // Outer loop for rows for (int i = 0; i < rows; ++i) { // Inner loop for columns for (int j = 0; j < cols; ++j) { cout << "*"; // Print a character for each column } cout << endl; // Move to the next line after each row } return 0; }
Output
Clear
ADVERTISEMENTS