C++ Online Compiler
Example: Filled Box in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Filled Box #include <iostream> using namespace std; int main() { int width, height; // Step 1: Get dimensions from the user cout << "Enter the width of the filled box: "; cin >> width; cout << "Enter the height of the filled box: "; cin >> height; // Step 2: Iterate through each row for (int i = 0; i < height; ++i) { // Step 3: Iterate through each column in the current row for (int j = 0; j < width; ++j) { cout << "*"; // Print asterisk for every position } cout << endl; // Move to the next line after each row } return 0; }
Output
Clear
ADVERTISEMENTS