How can draw a box in cprogram without using graphics.h
header file & using only one printf(); ?

Answer Posted / c.p.senthil

Generic Box routine,
to draw with prescribed length and width

// function defintion
void drawBox(int length, int width)
{
int i, j;

for(i=0; i<length; i++)
printf("_");
printf("\n");

for(j=0; j<width-1; j++)
{
printf("|");
for(i=0; i<(length-2); i++)
printf(" ");
printf("|");
printf("\n");
}

printf("|");
for(i=0; i<length-2; i++)
printf("_");
printf("|");
}

// function call
drawBox(30, 5);

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is typedef example?

603


Is c programming hard?

563


Is a house a mass structure?

632


What is a pragma?

658


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2679






What is calloc malloc realloc in c?

578


What is the purpose of main( ) in c language?

606


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

639


What is the scope of global variable in c?

543


Is int a keyword in c?

544


What does. int *x[](); means ?

624


ATM machine and railway reservation class/object diagram

4792


What is indirection?

637


Why header files are used?

629


What is difference between structure and union in c programming?

559