Functions and Recursions – Geometry – Problem #7

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

Problem Statement

Given three lines of the form ax+by=c, your program has to compute their points of intersection and hence the area of the triangle described by them. Take the co-efficients (a, b, c) of each line in main(). Then, write a function that takes as input (as parameter) the coefficients (a,b,c) of two lines and computes their intersection point if they are not mutually parallel. Call this function three times from main() and print required results (intersection points, side length, area, messages etc) in main() as shown in examples. You may use an array to pass the intersection points from function to main(). You can use sqrt function of math.h. Examples: $ Enter the coefficients (a, b, c) of three lines: Line 1: 1 0 0 Line 2: 0 1 0 Line 3: 1 1 1 Point of intersection between L1 and L2 = (0.000000, -0.000000). Point of intersection between L2 and L3 = (1.000000, 0.000000). Point of intersection between L3 and L1 = (-0.000000, 1.000000). Side lengths = 1.000000, 1.414214, 1.000000. Area = 0.500000 $ Enter the coefficients (a, b, c) of three lines: Line 1: 1 0 0 Line 2: 1 0 1 Line 3: 1 1 1 Lines 1 and 2 are parallel; so no point of intersection.

Back to Lab Problems
Functions and Recursions/Geometry/Problem #7

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #7

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.