on
CSS
- Get link
- X
- Other Apps
Variable Declaration
Outer Loop – Controls Rows
Inner Loop – Controls Columns
for (b = 0; b < n; b++)
Conditional Statement use
First Part:
Handles top and bottom row, but only middle part
a == 0 → first row (top of the O)
a == n-1 → last row (bottom of the O)
b > 0 && b < n-1 → avoid the corners
This draws the top and bottom horizontal lines of the 'O' (excluding corners).
Second Part:
b == 0 → first column (left edge)
b == n-1 → last column (right edge)
a > 0 && a < n-1 → avoid the top and bottom rows
This draws the left and right vertical lines of the 'O' (excluding corners).
Else Case
Comments
Post a Comment