Command Line Qns - Help!!! how to do

Qns:

Apply the syntax and structure of a C++ program in accessing and using the command line arguments. You are asked to implement a C++ program that reads from the command line three integers representing the three coordinates (x1, y1), (x2, y2) and (x3, y3).

Your program should do the following:
(a) Read in the values from the command line, the six integers represent x1, y1, x2, y2, x3, and y3 respectively. These three pairs of coordinates should form a triangle.
(6 marks)


Develop suitable coding modules in a typical multimedia application. With the input
from the command line, your program should perform three functions using independent
modules as follows:

(b) Calculate the length of each of the three sides of the triangle. For example, the
length of the side from (x1, y1) to (x2, y2) is given by the formula
√((𝑦2 − 𝑦1)2 + (𝑥2 − 𝑥1)2) --> *the 2 outside the brackets are square root*
(6 marks)

(c) Calculate the area of the triangle by using the formula
√(𝑠(𝑠 − 𝑎)(𝑠 − 𝑏)(𝑠 − 𝑐))

Where a, b, and c are lengths of the three sides of the triangle respectively and s is the semi-perimeter i.e. 𝑠 = (𝑎+𝑏+𝑐)/2
(4 marks)

I don't event know where to start especially part b and c finding the lenght and area.
Last edited on
Well for doing a square root you would use:

 
sqrt(x + y);


and then you would use pow for power.

 
pow(x + y, 2);


Both need math.h
Thank you, I have not really learnt that, as I missed some lessons, is there any samples I can refer to? please provide links if have. Thank you!
closed account (48T7M4Gy)
http://www.cplusplus.com/reference/cmath/
Thank you :)
Topic archived. No new replies allowed.