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.
- a = 1, b = 1, c = -1, x = -1, y = 1.
- a = 6, b = 8, c = 9, x = -3, y = 0.
- a = -1.1, b = -2.2, c = 9.9, x = 1.1, y = -3.3.
- a = -3.14, b = 2.78, c = -9.87, x = 2, y = 2.
Note
You may use the sqrt function of the math library (#include <math.h>). Also compile your program with the flag -lm.