C++ Online Compiler
Example: Number Rectangle Pattern in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Number Rectangle Pattern #include <iostream> using namespace std; int main() { int rows = 4; int cols = 5; // Outer loop for rows for (int i = 1; i <= rows; ++i) { // Using 1-based indexing for numbers // Inner loop for columns for (int j = 1; j <= cols; ++j) { cout << j << " "; // Print column number followed by a space } cout << endl; // Move to the next line after each row } return 0; }
Output
Clear
ADVERTISEMENTS