Lab 11 (C Programming) Solution

Mar 7, 2019

1)A circle having radius 100 pixels and center at point (150,250).

Source Code: 

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

int main()
{
  int gd = DETECT, gm;
  clrscr();
  initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  circle(150, 250, 100);
  getch();
  closegraph();
  return 0;
}

 

 

Output:

 circle

 

2)Two concentric circles having center point at (100,100). The inner circle should have radius 50 and outer have 75 pixels.

 

Source Code: 

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

int main()
{
  int gd = DETECT, gm;
  clrscr();
  initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  circle(100, 100, 50);
  circle(100, 100, 75);
  getch();
  closegraph();
  return 0;
}

 

 

Output:

circle

 

3)A rectangle which has left top corner point at (50, 75) and right bottom point at (200,250).  

 

Source Code: 

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

int main()
{
  int gd = DETECT, gm;
  clrscr();
  initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  rectangle(	50, 75, 200, 250);
  getch();
  closegraph();
  return 0;
}

 

 

Output:  

 

rectangle

 

5)A rectangle having a diagonal of length 100 pixels and its one end at point (10, 20).

 

Source Code: 

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

int main()
{
  int gd = DETECT, gm;
  clrscr();
  initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  rectangle(	10, 20, 70, 100);
  getch();
  closegraph();
  return 0;
}

 

 

Output:

 rectangle

 

 

6)An ellipse having xRadius=100, yRadius=50 and center atpoint (100, 50).

 

Source Code: 

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

int main()
{
  int gd = DETECT, gm;
  clrscr();
  initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  ellipse(100, 50, 0, 360, 100, 50);
  getch();
  closegraph();
  return 0;
}

 

Output:

ellipse