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 dynamic dispatch in c++?
What is typedf?
What are pointers? What are different types of pointers?
What is an array? What the different types of arrays in c?
What is the general form of a C program?
What are the differences between new and malloc in C?
What is malloc() function?
What is return type in c?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What is spaghetti programming?
What are the types of c language?
Explain two-dimensional array.
What is the difference between malloc() and calloc()?
When should the volatile modifier be used?
What is the use of c language in real life?