Like this
Code:
#include <stdio.h>
void display( char icon, int length, int width );
int main(void) {
int length, width;
char icon;// icon is the character that is used for the display
printf( "This program draws a hollow rectangle using a character of your choice\n\n" );
printf( "Choose character for display\n " );
scanf( "%c", &icon );
printf( "Enter length: " );
scanf( "%d",&length );
printf( "Enter width: " );
scanf( "%d",&width );
display( icon, length, width );
return 0;
}
void display( char icon, int length, int width ) {
int inner, outer;// loop control varibles
for(inner = 0; inner < width; inner ++)// prints top row of icons
printf( "%c",icon );
printf( "\n" );
for(inner = 0; inner < length; inner ++)// prints both sides starting with left
{
printf( "%c",icon );
for(outer = 0; outer < (width-2); outer ++)// prints spaces to where the right column should be
printf( " " );
printf( "%c",icon );// prints an icon in the right column
printf( "\n" );
}// end for
for(inner = 0; inner < width; inner ++)// prints bottom row of icons
printf( "%c",icon );
printf( "\n\n" );
}