CS13002 Programming and Data Structures

Section: 4/D, Spring 2005

Assignment 1

This assignment deals with the concept of simple assignments and with simple branching instructions.

A circle (in the two-dimensional real plane) is defined in terms of three real numbers a,b,c. The defining equation is taken to be:

   x2 + y2 + ax + by + c = 0.

Input three real numbers a,b,c from the user. Then determine if these three numbers define a circle. If not, print a diagnostic message and quit. Otherwise determine (and print) the center and radius of the circle. Also input the coordinates of a point. Print whether this new point lies on, inside or outside the circle.

Sample run

   Enter the coefficients of the defining equation :
   a = 1
   b = 1
   c = 1
   These a,b,c do not define a circle.

   Enter the coefficients of the defining equation :
   a = 3
   b = -2
   c = -0.75
   The circle has center at (-1.500000,1.000000) and radius 2.000000.
   Enter the coordinates of a point :
   x = 0
   y = 0
   The point is inside the circle.

Test output

Report the output of your program on the following input values. Ignore the x,y values, if they are not needed.


You may use the sqrt function of the math library (#include <math.h>). Also compile your program with the flag -lm.

[Submission site] [Lab home] [Course home]