Print Box

PHOTO EMBED

Sat Jun 08 2024 22:11:09 GMT+0000 (Coordinated Universal Time)

Saved by @meanaspotato #c

#include <stdio.h>

// Function to print the top part of the decorative box
void print_top() {
    printf("/\\/\\/\\/\\/\\\n");
}

// Function to print the bottom part of the decorative box
void print_bottom() {
    printf("\\/\\/\\/\\/\\/\n");
}

// Function to print the middle part of the decorative box
void print_middle(int how_many) {
    for (int i = 0; i < how_many; i++) {
        printf("\\        /\n");
        printf("/        \\\n");
    }
}

// Main function to demonstrate the functionality
int main() {
    int how_many;

    // Prompt the user for the number of middle parts
    printf("How many middle parts? \n");
    scanf("%d", &how_many);

    // Print the top part
    print_top();
    
    // Print the middle part specified number of times
    print_middle(how_many);
    
    // Print the bottom part
    print_bottom();
    
    return 0;
}
content_copyCOPY

Objective: Create a modularized program that prints a decorative box with parts that can be controlled by the user. Functions to Implement: Function name: print_top Parameters: None Functionality: Outputs the top part of the decorative box as: /\/\/\/\/\ Make sure to include a newline at the end. Function name: print_bottom Parameters: None Functionality: Outputs the bottom part of the decorative box as: \/\/\/\/\/ Remember to include a newline at the end. Function name: print_middle Parameters: how_many: An integer indicating how many times to print the middle part. Functionality: Repeatedly outputs the middle part of the decorative box the specified number of times: \ / / \ Each repetition should be followed by a newline.