CS13002 Programming and Data Structures

(Autumn semester)    Section A

Assignment Set - 3

Please write your Roll Number, Name and Assignment Number at the header of each program.


Assignment 3.a:        Filename: a3a.c

Rewrite the program for finding roots (Assignment 1b) using a function that returns the value of f(x) for a given value of x, where:

    f(x) = ( x2 - 10x + 16 )( log4 x - 2 )

To copy the file a1b.c to a3a.c use the command cp a1b.c a3a.c from the command prompt.


Assignment 3.b:        Filename: a3b.c

Write a function dist(x1, y1, x2, y2) that returns the Euclidean distance between two points (x1,y1) and (x2,y2). Write a program that reads the coordinates of three points, (x1,y1), (x2,y2), (x3,y3), and uses this function to find the closest pair of points. It then prints the coordinates of the closest pair and the distance between them.

Would it be prudent to use the above function to determine whether the three points are collinear? Or to determine whether the triangle formed by the three points is a right angled triangle, using say Pythagoras theorem?


Course home