Description
Part 0. Write a complete C program (in main.c) that takes the coordinates of two points A(xi, yi) and B(x2, y2) on the cartesian plane (as integers) and perform the following tasks. PS: Don’t use any library other than stdio.h.
Part 1. (25 pts) Midpoint Calculation: The program calculates the coordinates of the midpoint of these points and prints it out.
Part 2. (25 pts) Slope Calculation: The program calculates the slope of the line that passes through these points and prints it out.
Part 3. (25 pts) Area Calculation (Circle): Assuming that the line segment between A and B is the diameter of a circle and midpoint is the center, the program computes and prints out the area of this circle.
Part 4. (25 pts) Create a makefile to compile and run the program by creating main.o and main.out files respectively. Your makefile should perform the following commands: clear (the terminal), clean (the files), compile and run.
Formulas:
Input Points : A(xi, Y1) and B(x2, Y2)
() Midpoint : M(x, y) = xi + x2 yl + Y2 2                     ‘ 2 — Slope : m — y2– Y1 X2 – Xi Area of the circle : A = 7rr2 (7r = 3. 14) Distance between two points A(xi,      ) and B(x2, Y2): AB = (x2 — x1)2 + (Y2 — )2 |
|
|
|