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
What is typedef example?
Is c programming hard?
Is a house a mass structure?
What is a pragma?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
What is calloc malloc realloc in c?
What is the purpose of main( ) in c language?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What is the scope of global variable in c?
Is int a keyword in c?
What does. int *x[](); means ?
ATM machine and railway reservation class/object diagram
What is indirection?
Why header files are used?
What is difference between structure and union in c programming?