ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
how can u draw a rectangle in C
 Question Submitted By :: Sandipan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how can u draw a rectangle in C
Answer
# 1
BY USING PRINTF AND SCANF
 
Is This Answer Correct ?    27 Yes 69 No
Vincent
 
  Re: how can u draw a rectangle in C
Answer
# 2
Using a rectangle(int,int,int,int)function of c graphics.
 
Is This Answer Correct ?    100 Yes 16 No
Ketan Bhavsar
 
 
 
  Re: how can u draw a rectangle in C
Answer
# 3
using include<graphic.h>
 
Is This Answer Correct ?    57 Yes 15 No
Soumya
 
  Re: how can u draw a rectangle in C
Answer
# 4
using ASCII codes and then using goto statements
 
Is This Answer Correct ?    9 Yes 43 No
Sumit
 
  Re: how can u draw a rectangle in C
Answer
# 5
using rectangle(int,int,int,int)
               <left,top,right,bottom>
it is a function in graphics.h
 
Is This Answer Correct ?    55 Yes 11 No
M.d.balaji
 
  Re: how can u draw a rectangle in C
Answer
# 6
USING rectangle(int,int,int,int)
it is a function in graphics.h
 
Is This Answer Correct ?    30 Yes 10 No
M.d.balaji
 
  Re: how can u draw a rectangle in C
Answer
# 7
including graphics.h
then initialising graphics system using initgraph
and using the function rectangle(int left,int top,int 
right,int bottom)
 
Is This Answer Correct ?    30 Yes 6 No
Sala
 
  Re: how can u draw a rectangle in C
Answer
# 8
no answer
 
Is This Answer Correct ?    7 Yes 22 No
Guest
 
  Re: how can u draw a rectangle in C
Answer
# 9
using rectangle(int right,int top,int left,int bottom) in 
graphics.h
 
Is This Answer Correct ?    14 Yes 10 No
Suganya
 
  Re: how can u draw a rectangle in C
Answer
# 10
first include the graphics.h file 
thus you can use the rectangle funtion give the proper 
parameters and the wor is done
 
Is This Answer Correct ?    9 Yes 10 No
Azad
 
  Re: how can u draw a rectangle in C
Answer
# 11
Divide by Zero.
 
Is This Answer Correct ?    3 Yes 30 No
Anonymous
 
  Re: how can u draw a rectangle in C
Answer
# 12
BY using #include<graphics.h>
we can draw rectangle.
The syntax is rectangle(int ,int ,int ,int)
{left,top,right,bottom}
 
Is This Answer Correct ?    18 Yes 6 No
Venkat
 
  Re: how can u draw a rectangle in C
Answer
# 13
printf("____________________");
printf("\n|\t\t|\n|\t\t|\n|\t\t|\n|\t\t|");
printf("____________________");

    by this way i think can be possible,though some 
adjustment may required...as per size of VDU.As per my 
opinion intervier asked for this answer....as C graphics is 
not so popularly used.
     Pardon me if i'm wrong & can also mail to me.
 
Is This Answer Correct ?    8 Yes 21 No
Subhradip
 
  Re: how can u draw a rectangle in C
Answer
# 14
line(x1,y1,x2,y1)
line(x1,y2,x2,y2)
line(x1,y1,x1,y2)
line(x2,y1,x2,y2)
 
Is This Answer Correct ?    18 Yes 9 No
Venkatesh
 
  Re: how can u draw a rectangle in C
Answer
# 15
/*  simple.c
    example 1.0
*/
#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 ?    32 Yes 3 No
Raj
 
  Re: how can u draw a rectangle in C
Answer
# 16
/*  simple.c
    example 1.0
*/
#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 ?    20 Yes 4 No
Mahendra Microsoft
 
  Re: how can u draw a rectangle in C
Answer
# 17
#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 ?    19 Yes 4 No
Sunny Khanna
 
  Re: how can u draw a rectangle in C
Answer
# 18
line(x1,y1,x2,y1)
line(x1,y2,x2,y2)
line(x1,y1,x1,y2)
line(x2,y1,x2,y2)

initgraph(&gd, &gm, "c:\\turboc3\\bgi " );
    rectangle(200,50,350,150);
 
Is This Answer Correct ?    8 Yes 6 No
Santosh
 
  Re: how can u draw a rectangle in C
Answer
# 19
to use follows

rect(x1,y1.x2,y2);
 
Is This Answer Correct ?    4 Yes 8 No
Arthanari R
 
  Re: how can u draw a rectangle in C
Answer
# 20
using turboc2 editor
 
Is This Answer Correct ?    3 Yes 12 No
Ganesh
 
  Re: how can u draw a rectangle in C
Answer
# 21
using pen & scale
 
Is This Answer Correct ?    4 Yes 21 No
Shiju
 
  Re: how can u draw a rectangle in C
Answer
# 22
First we insert the graphics mode into your complier,and we
use the function rectangle(); in the rectangle function we
specified the length and breath,and we also specified where
the place in screen the rectangle is drawn.
 
Is This Answer Correct ?    2 Yes 9 No
Senthilkumar
 
  Re: how can u draw a rectangle in C
Answer
# 23
include graphics.h

rectangle(int,int,int,int)

closegraph()
 
Is This Answer Correct ?    6 Yes 7 No
Shruti
 
  Re: how can u draw a rectangle in C
Answer
# 24
include the header file graphics.h 
use the built in function rect(x1,y1,x2,y2)
such that (x1,y1) and (x2,y2) are the coordinates
 
Is This Answer Correct ?    4 Yes 7 No
Ram Kumar
 
  Re: how can u draw a rectangle in C
Answer
# 25
#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 ?    9 Yes 6 No
Prabhanjan
[Mlr Engineering College]
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
How to swap two variables, without using third variable ? HCL48
Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])  1
main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?  1
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }  1
How to reverse a String without using C functions ? Wipro14
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }  1
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }  1
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. Wipro2
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }  1
void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }  1
#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }  1
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.  5
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }  1
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }  1
main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }  1
program to Reverse a linked list Ness-Technologies4
main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above HCL1
main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }  1
main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }  1
Write a procedure to implement highlight as a blinking operation  1
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com