CS 2073 Computer Programming 

with Engineering Applications

Instructor Dr. Turgay Korkmaz
Sample Homework 1


Background: General equation for a line is Ax + By + C = 0   (A, B, C const). 

Suppose we have two different lines A1x + B1y + C1 = 0  and A2x + B2y + C2 = 0.

To find the intersection point of these lines, we can use the following formulas:

 and  

Determinant of second order is computed as follows

= A1*B2 – A2*B1

 

HW Question:

Write a program that asks user to enter A1, B1, C1 for the first line and A2, B2, C2 for the second line, and then computes the intersection point x0 and y0 and prints them out.

Don’t forget to include comments about the problem, yourself and each major step in your program!

What to return:                !!!!  NO LATE HOMEWORK WILL BE ACCEPTED  !!!

Give me the printout of our source program (e.g., intersection.c) and outputs for two different runs.

 

 

 

 

 

Note:

When entering A1, B1, C1 for the first line and A2, B2, C2 for the second line, make sure  is not zero.

Because If  == 0, the lines are parallel.

We will take care of such cases after studying if-then-else statements.