Starting from:

$25

CSE108 - Computer Programming Laboratory - Lab 1 - Solved

Part O. Write a complete C program (in main.c) that takes the coordinates of two points A(XI, h) and B(X2, h) 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 :  

Midpoint : M(c, y)  

Slope : m —  x

Area of the circle : A =                   (T 3. 14)

Distance between two points A(CI, VI) and B(C2, (c2 — Cl)2 + (Y2

 Example input and output:

                                                             q

More products