Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 dynamic dispatch in c++?

1046


What is typedf?

1119


What are pointers? What are different types of pointers?

1128


What is an array? What the different types of arrays in c?

1171


What is the general form of a C program?

1022


What are the differences between new and malloc in C?

1133


What is malloc() function?

1149


What is return type in c?

1128


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

1148


What is spaghetti programming?

1119


What are the types of c language?

1021


Explain two-dimensional array.

1052


What is the difference between malloc() and calloc()?

1826


When should the volatile modifier be used?

1167


What is the use of c language in real life?

1015