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
Write a program to print "hello world" without using a semicolon?
Explain what is meant by 'bit masking'?
What are file streams?
What is a stream?
Can one function call another?
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is null in c?
What are the 4 types of programming language?
How many levels of indirection in pointers can you have in a single declaration?
Explain what are linked list?
What are the advantages of Macro over function?
Describe newline escape sequence with a sample program?
In a switch statement, explain what will happen if a break statement is omitted?
What is the explanation for prototype function in c?
Explain how can you tell whether two strings are the same?