CS19002 Programming and Data Structures Laboratory |
Spring 2009, Section 2 |
Assignment 0
(Simple statements, variables and assignments)
Write a C program that computes the area of a triangle. Proceed as follows.
- Read the x and y coordinates of the three vertices of a triangle.
- Compute the lengths a, b and c of the three sides of the triangle.
- Compute the semiperimeter s = (a + b + c) / 2.
- Compute the area A = [s (s - a) (s - b) (s - c)]1/2.
- Print the area A.
Report the output of your program on the following inputs.
- (3,8), (4,2), (5,9)
- (-1.1,-1.1), (2.2,-3.3), (-4.4,5.5)
- (-2,9), (3,4), (8,-1)
Submission site | Lab home | Course home | My home