CSE108 Lab 1 Solved

30.00 $

Category: Tags: , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

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 — y2Y1

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

 

 

 
Example input and output:
 
xl: 5 yl: 6 x2: -10

y2: -5

Midpoint: M(x,y) = (-2.5, 0.5) Slope: pi = (0.7)

Area: A = 271.6

 

 

1/1

  • lab1-xtlfjm.zip