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

Explain the difference between malloc() and calloc() function?

799


What is pointers in c?

887


Where can I get an ansi-compatible lint?

879


What is identifier in c?

761


What are the benefits of organizational structure?

770


What is the scope of local variable in c?

778


How to write a code for reverse of string without using string functions?

1826


What are the types of macro formats?

805


Can we compile a program without main() function?

870


a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

4804


What is the significance of an algorithm to C programming?

790


What is a pragma?

880


How do you define structure?

786


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1577


What is the difference between union and anonymous union?

1038