void Functions

Lab C Beginner 10 points

Write void print_line(char c, int n) that prints n copies of c and a new line. Read a character and a size, and print a hollow square border of that size.

Input

One line: char n (n ≥ 2).

Output

n rows.

Example

Input

# 4

Output

####
#  #
#  #
####
Sample input available Sample output available
Editor
C

Hints

void means the function returns nothing.

Solution explanation

Reusing print_line for the top and bottom avoids duplicate code.

Show solution
#include <stdio.h>

void print_line(char c, int n) {
    for (int i = 0; i < n; i++) printf("%c", c);
    printf("\n");
}

int main() {
    char c;
    int n;
    scanf(" %c %d", &c, &n);
    print_line(c, n);
    for (int r = 0; r < n - 2; r++) {
        printf("%c", c);
        for (int i = 0; i < n - 2; i++) printf(" ");
        printf("%c\n", c);
    }
    print_line(c, n);
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD