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

Write a program to print "hello world" without using a semicolon?

1115


Explain what is meant by 'bit masking'?

1264


What are file streams?

1066


What is a stream?

1192


Can one function call another?

1171


Discuss the function of conditional operator, size of operator and comma operator with examples.

1205


What is null in c?

1151


What are the 4 types of programming language?

1187


How many levels of indirection in pointers can you have in a single declaration?

1141


Explain what are linked list?

1089


What are the advantages of Macro over function?

2090


Describe newline escape sequence with a sample program?

1167


In a switch statement, explain what will happen if a break statement is omitted?

1122


What is the explanation for prototype function in c?

1029


Explain how can you tell whether two strings are the same?

1077