Question: Instructions: - Step 1 : Write the C source code ( named as pe 2 . c ) with vim by using the

Instructions:
- Step 1: Write the C source code (named as "pe2.c") with vim by using the command: vim pe2.c
(a) Write a function to find and return the slope of a line. The equation to calculate the slope from two points is given as: \( m=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}\). Call this function twice to compute \( m_{1}\) and \( m_{2}\).
(b) Write a function to find and return the y -intercept of a line. Note that the y intercept of a line is the value of y at the point where the line crosses the y axis, i.e., when \( x=0\). Call this function twice to compute \( b_{1}\) and \( b_{2}\).
(c) Write a function to compute and return the angle between the two lines. Note that the angle \(\theta \) between the lines having slope \( m_{1}\) and \( m_{2}\) is given by \(\theta=\)\(\arctan \left(\frac{m_{1}-m_{2}}{1+m_{1} m_{2}}\right)\). You may use atan function given in math. \( h \) to compute arctan.
(d) Write a function to print the two line equations, check if the two lines are parallel or intersect using the angle between the two lines. Note that if \(\theta\epsilon \) where \(\epsilon \) is a predefined small number, we assume the lines are parallel.
- Step 2: Build your executable program named as "pe2" by using the command: gcc -o pe2 pe2.c
- Step 3: Run the program by using the command: ./pe2
- Step 4: Test your code with the provided "test2.sh" file by using the command: -/test2.sh pe2.c
Note 1: You should have the "test2.sh" in the same directory as your source code.
Note 2: You should see "PASS" for all the test cases.
- Step 5: Submit your source code ("pe2.c") to Learn.Hub (assignment "PE2").
Sample Result
```
Zafers-MacBook-Pro:src zafer$ ./fpex
Enter coordinates of two points on line 1[x1,y1,x2,y2]:
0.20.42.1-.4
Enter coordinates of two points on line 2: [x3,y3,x4,y4]:
0.72.83.20
The equation of l1: y =-0.42x+0.48.
The equation of 12: y =-1.12x+3.58.
l1 and l2 lines intersect, and the angle between the two lines is 25.41.
Zafers-MacBook-Pro:src zafer$ ./fpex
Enter coordinates of two points on line 1[x1,y1,x2,y2]:
1324
Enter coordinates of two points on line 2: [x3, y3,x4,y4]:
2604
The equation of l1: y =1.00x+2.00.
The equation of 12: y =1.00x+4.00.
l1 and l2 lines are parallel, and the angle between the two lines is 0.00.
Zafers-MacBook-Pro:src zafer$ ./fpex
Enter coordinates of two points on line 1[x1,y1,x2,y2]:
1328
Enter coordinates of two points on line 2:[x3,y3,x4,y4]:
3256
The equation of 11: y =5.00x-2.00.
The equation of l2: y =2.00x-4.00.
l1 and l2 lines intersect, and_the angle between the two lines is 15.26.
```
Instructions: - Step 1 : Write the C source code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!