Member-only story
Write a Fun Program to Draw a House
3 min readOct 5, 2023
Learn how to draw a house using the C-Programming language.
In this article, I wanted to introduce some fun code. This isn’t much of an article, just me sharing some code! So, I hope you all enjoy! The code below Created a image of a “house” using only keyboard characters.
#include <stdio.h>
int main() {
// Declare two integers i and j
int i, j;
// Iterate from 1 to 25
for (i = 1; i <= 25; i++) {
// Iterate from 1 to 40
for (j = 1; j <= 40; j++) {
// Check if i is between 1 and 11
if (i >= 1 && i <= 11) {
// Check if i is equal to 1 and j is between 11 and 30
if (i == 1 && j >= 11 && j <= 30) {
// Print a "-" character
printf("-");
} else if (i > 1 && (12 - i) == j) {
// Print a "/" character
printf("/");
} else if (i > 1 && (29 + i) == j) {
// Print a "\\" character
printf("\\");
} else if (i <= 11 && (10 + i) == j) {
// Print a "\\" character
printf("\\");
} else if ((12 - i) <= j && (10 + i) >= j) {
// Print a "P" character
printf("P");
} else if ((10 + i) <= j && (29 + i) >= j) {
// Print a "V" character
printf("V");
} else {
// Print a space character
printf(" ");
}
} else if (i <= 16) {
// Check if j…