how can u draw a rectangle in C

Answers were Sorted based on User's Feedback



how can u draw a rectangle in C..

Answer / rahul singh

Firstly we can use header file............
#include<graphics.h>

Steps to make rectangle in c.

1.Make main function
2.Detect graphic by using (int a=DETECT),(initgraph(&a,"c:\
\tc\\bgi");
3. Now use the value of x and y cordinates.
4. After that use the func. rectangle(int,int,int,int).
5. Now use line(0,0,0,0) set the value according to
u...........

Is This Answer Correct ?    5 Yes 2 No

how can u draw a rectangle in C..

Answer / sandeep mishra

With the help of

rectangle(int x1,int y1, int x2 ,int y2)

we pass 4 parameter x1 , y1 ,x2, y2 ;
where x1 is top left co-ordinate
y1 is top right co-ordinate
x2 is bottom left co-ordinate
y2 is bottom right co-ordinate

Is This Answer Correct ?    3 Yes 0 No

how can u draw a rectangle in C..

Answer / aishwarya

using initgraphics fn and rectangle(int left ,int top,int
right,int bottom)

Is This Answer Correct ?    3 Yes 0 No

how can u draw a rectangle in C..

Answer / ramesh b penchal

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int driver,mode,x1,y1,x2,y2;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
printf("Enter(x1,y1) and (x2,y2) co-ordinate values");
scanf("%d%d %d%d",&x1,&y1,&x2,&y2);
rectangle(x1,y1,x2,y2);
getche();
closegraph();
}

Is This Answer Correct ?    5 Yes 3 No

how can u draw a rectangle in C..

Answer / chinnadurai.s

Draws a rectangle (graphics mode)

Declaration:
void far rectangle(int left, int top, int right, int bottom);
draw a rectangle in c using the header file for
#include<graphics.h> and using function for
rectangle(int,int,int,int);

for example

rectangle (int x1,int y1,int x2,int y2)
x1,x2,y1,y2 is an integer datatypes and given the values.

rectangle(100,150,200,250);

Is This Answer Correct ?    4 Yes 2 No

how can u draw a rectangle in C..

Answer / dinesh

rectangle(int,int,int,int);

Is This Answer Correct ?    2 Yes 0 No

how can u draw a rectangle in C..

Answer / ripesh

Three ways as far as I read throught web and book
1 Using printf
2 Using rectangle function(int,int,int,int)
3 Using line function with appropriate coordinates

It's up to you.. first one doesn't require mode to be set
graphic.

Is This Answer Correct ?    2 Yes 0 No

how can u draw a rectangle in C..

Answer / ankit limbachiya

#include<graphics.h>
#include<conio.h>

void main()
{
int gdrive=DETECT, gmode;

initgraph(&gdrive, &gmode, "c:\\turboc3\\bgi " );
rectangle(200,50,350,150);

getch();
closegraph();
}

Is This Answer Correct ?    3 Yes 1 No

how can u draw a rectangle in C..

Answer / rakesh

#include<stdio.h>
#define n 5
#define m 4
int main()
{ int i,j;
printf("%c",218);
for(i=1;i<=n;i++)
printf("%c",196);
printf("%c",191);
for(i=1;i<=m;i++)
{ printf("\n%c",179);
for(j=1;j<n;j++)
printf(" ");
printf(" %c",179);
}
printf("\n%c",192);
for(i=1;i<=n;i++)
printf("%c",196);
printf("%c",217);
getch();
return(0);
}
you can change the dimensions by changing n and m.

Is This Answer Correct ?    2 Yes 1 No

how can u draw a rectangle in C..

Answer / ankita vaidya

use #include<graphic.h> in the header file

den accept the 2 co-ordinates of opposite vertices of the diagonal

and use rectangle(int x.topleft,int y.topleft , int x.bottomright,int y.bottomright);

here (x.topleft.y.topleft) are co-ordinates of top-left vertex
and (x.bottomright,y.bottomright) are co ordinates of bottom right vertex.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above

3 Answers   BrickRed, HCL,


#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }

1 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


Find the largest number in a binary tree

7 Answers   Infosys,


main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16

4 Answers   HCL,






#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

2 Answers   CNSI,


How we print the table of 2 using for loop in c programing?

14 Answers   HCL, Wipro,


#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer

1 Answers  


#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }

2 Answers  


const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above

1 Answers   emc2, HCL,


Finding a number multiplication of 8 with out using arithmetic operator

8 Answers   Eyeball, NetApp,


Question: We would like to design and implement a programming solution to the reader-writer problem using semaphores in C language under UNIX. We assume that we have three readers and two writers processes that would run concurrently. A writer is to update (write) into one memory location (let’s say a variable of type integer named temp initialized to 0). In the other hand, a reader is to read the content of temp and display its content on the screen in a formatted output. One writer can access the shared data exclusively without the presence of other writer or any reader, whereas, a reader may access the shared memory for reading with the presence of other readers (but not writers).

1 Answers  


Categories