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 getch() function?

650


What is the time and space complexities of merge sort and when is it preferred over quick sort?

677


When c language was developed?

643


What is c standard library?

693


What does a function declared as pascal do differently?

608






Explain what is a stream?

609


Tell me can the size of an array be declared at runtime?

600


What are type modifiers in c?

624


What is a null string in c?

590


In c programming language, how many parameters can be passed to a function ?

632


Why we write conio h in c?

568


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

600


Explain Basic concepts of C language?

647


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

770


What is bss in c?

606