how can u draw a rectangle in C
Answers were Sorted based on User's Feedback
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 |
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 |
Answer / aishwarya
using initgraphics fn and rectangle(int left ,int top,int
right,int bottom)
| Is This Answer Correct ? | 3 Yes | 0 No |
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 ? | 4 Yes | 1 No |
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 |
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 |
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 |
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 |
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 |
Write a program that produces these three columns sequence nos. using loop statement Sequence nos. Squared Squared + 5 1 1 6 2 4 9 3 9 14 4 16 21 5 25 30
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
#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); }
write a c program to Create a mail account by taking the username, password, confirm password, secret_question, secret_answer and phone number. Allow users to register, login and reset password(based on secret question). Display the user accounts and their details .
prog. to produce 1 2 3 4 5 6 7 8 9 10
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
could you please send the program code for multiplying sparse matrix in c????
how can u draw a rectangle in C
53 Answers Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,
#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
Find your day from your DOB?
15 Answers Accenture, Microsoft,