how can u draw a rectangle in C
Answers were Sorted based on User's Feedback
Answer / sunny khanna
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
rectangle(100,100,250,250);
getche();
closegraph();
}
Is This Answer Correct ? | 46 Yes | 11 No |
Answer / venkatesh
line(x1,y1,x2,y1)
line(x1,y2,x2,y2)
line(x1,y1,x1,y2)
line(x2,y1,x2,y2)
Is This Answer Correct ? | 51 Yes | 17 No |
Answer / srinivas.m
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT, gm;
initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
rectangle(200,50,350,150);
getch();
closegraph();
}
Is This Answer Correct ? | 24 Yes | 4 No |
Answer / shrikant
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the value of n\n");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=0;j<=2*n;j++)
{
if((i>0 && i<n) && (j>0 && j<2*n))
{
printf(" ");
}
else
{
printf("* ");
}
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 23 Yes | 4 No |
Answer / prabhanjan
#include
#include
#include
main()
{
int gd=DETECT, gm,x,y;
int arr[]={540,220,590,270,570,320,510,320,490,270,540,220};
initgraph(&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
setcolor(GREEN);
printf(" \n value of x = %d",x);
printf(" and the value of y = %d",y);
rectangle(5,40,140,200);
outtextxy(x/30+15,y/8+5,"Rectangle");
drawpoly(6,arr);
outtextxy(515,270,"Polygon");
setcolor(RED);
line(0,49,639,479);
line(0,0,0,479);
line(0,0,639,0);
line(639,0,639,479);
getch();
closegraph();
restorecrtmode();
}
Is This Answer Correct ? | 21 Yes | 13 No |
Answer / sabarinathan
void main()
{
int n=0,i=0;
printf("how many lines should rectangle can occupied");
scanf("%d",n);
printf("____________");
prinf("/n");
for(i=0;i<=n;i++)
{
printf("| |");
printf("/n");
}
printf("____________")
}
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / joker
why do you want to draw rectangle using C if you can do it
in a paper its more simpler and faster, no developer
required hence cost effective.
Is This Answer Correct ? | 9 Yes | 5 No |
Answer / vignesh
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
int main()
{
int driver,mode;
detectgraph(&driver,&mode);
initgraph(&driver,&mode,"...\\bgi");
setcolor(8);
for(i=10;i<201;i++)
{
sound(i);
rectangle(200,50,350,150);
delay(1000);
nosound();
}
getch();
}
Is This Answer Correct ? | 7 Yes | 4 No |
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).
can u give me the c codings for converting a string into the hexa decimal form......
#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }
what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }
What is your nationality?
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }
main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error
main() { extern int i; i=20; printf("%d",sizeof(i)); }
4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
void main() { int const * p=5; printf("%d",++(*p)); }
3 Answers Infosys, Made Easy, State Bank Of India SBI,
Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];