Functions and Recursions – Geometry – Problem #1

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

Difficulty: medium

Problem Statement

Consider the following function prototype. int check_triangle(float l1, float l2, float l3); The function takes three real numbers, l1, l2 and l3 as lengths of straight line segments, and returns an integer subject to possibility of forming a geometric shape as stated below: 0: neither a straight line, nor a triangle. 1: a straight line 2: a non-right angled and non-equilateral triangle 3: a right angled triangle 4: an equilateral triangle Suppose a triplet (lt1, lt2, lt3) denote the lengths of three straight line segments. Write a C-program to implement the above function and the program reads N triplets of lengths in three different arrays for lt1, lt2 and lt3, respectively. It prints the statement of geometric shape from the return value of the function for each of the triplet. It also prints the numbers of triangles, straight lines, right angles and equilateral angles those are possible to form from the set of triplets. Run the program with the following input data set: (i) N=10 (3, 5, 7), (2, 10, 4), (1, 2, 3), (3, 4, 5), (6, 6, 6), (12, 13, 5), (8, 15, 7), (100, 300, 15), (89, 89, 89), (23, 37, 47) (ii) N=10 (3.2, 5.3, 7.8), (2.2, 10.9, 4.7), (1.2, 2.2, 3.2), (3.7, 4.9, 5.2), (6.6, 6.6, 6.6), (12, 13, 5), (8, 15, 7), (100, 300, 15), (89, 89, 89), (23.2, 37.9, 47.1)

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

Lab Problem Statement

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

Interactive C Compiler · Problem #1

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.