C programmer

profilekalza
in_class_problem_1.pdf

Writing a small C program

In Class Problem 1

General problem statement

 Write a program that will indicate whether two

straight lines intersect. Each line is specified by

giving two points (xi,yi) that are on the line.

 Do you understand what data will be input?

 What will the answer look like?

 Can you write some pseudo-code for the

solution?

How do we represent the lines?

 Slope-intercept form works: y = mx + b, where

m= (y1 – y2) / (x1 – x2)

 What property of straight lines can we exploit to

make this problem easier?

 Let’s take care of the special cases

CARTESIAN COORDINATES

A graphical view

(x1,y1)

(x2,y2)

1-1

1

-1