C Online Compiler
Example: Solid Rectangle Pattern in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Solid Rectangle Pattern #include <stdio.h> int main() { // Step 1: Declare variables for rows and columns int rows, columns; // Step 2: Get user input for dimensions printf("Enter the number of rows: "); scanf("%d", &rows); printf("Enter the number of columns: "); scanf("%d", &columns); printf("\nSolid Rectangle Pattern:\n"); // Step 3: Outer loop for rows // This loop iterates 'rows' times, with each iteration representing a new line (row). for (int i = 0; i < rows; i++) { // Step 4: Inner loop for columns // This loop iterates 'columns' times for each row, printing a character. for (int j = 0; j < columns; j++) { printf("*"); // Print the desired character (e.g., asterisk) } printf("\n"); // Move to the next line after all characters for the current row are printed } return 0; }
Output
Clear
ADVERTISEMENTS