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 are header files and what are its uses in C programming?
please send me the code for multiplying sparse matrix using c
What are the features of c language?
Explain goto?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
Write a program to know whether the input number is an armstrong number.
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
What is use of integral promotions in c?
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What are the ways to a null pointer can use in c programming language?
Differentiate fundamental data types and derived data types in C.
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
When should we use pointers in a c program?
What is bubble sort technique in c?
How to define structures? ·