Print ASCII Triangle

PHOTO EMBED

Sat Jun 08 2024 21:53:55 GMT+0000 (Coordinated Universal Time)

Saved by @meanaspotato #c

#include <stdio.h>

void print_ascii_rectangle(char symbol, int width, int height)
{
    for(int i =0;i<height;i++)
    {
        for(int j=0;j<width;j++)
        {
            printf("%c",symbol);
        }
        printf("\n");
    }
}

int main()
{
    char symbol;
    int width;
    int height;
    printf("Please enter an ASCII symbol:\n");
    scanf(" %c",&symbol);
    
    printf("Please enter the width:\n");
    scanf("%d",&width);
    printf("Please enter the height:\n");
    scanf("%d",&height);
    print_ascii_rectangle(symbol,width,height);
}
content_copyCOPY

Objective: Develop a function to display an ASCII rectangle based on user-specified parameters. Function to Implement: Function name: print_ascii_rectangle Parameters: symbol: A character representing the ASCII symbol used to draw the rectangle. width: The width of the rectangle. height: The height of the rectangle. Functionality: Outputs a rectangle using the given symbol with the specified width and height. Flow of Main Function: Prompt the user for an ASCII symbol to be used for drawing the rectangle. Request the width of the rectangle as a whole number. Request the height of the rectangle as a whole number. Call the print_ascii_rectangle function with the provided symbol, width, and height to display the rectangle. For example: Input Result # 3 2 Please enter an ASCII symbol: Please enter the width: Please enter the height: ### ###