You are on page 1of 1

#include <iostream>

#include <cmath>

using namespace std;

int main()
{
float angle1, distance, side1, side2, angle, cosine, squared, area; //the variables and data type
const float Pl= 3.14159265358979323846; // the pi
cout <<"Find the missing value of one side and the area "<<endl;
cout <<"using the law of cosine and the formula for the area of oblique triangles."<< endl; //A
sentence

//output

cout<<"Enter the value of one side: ";//sentence


cin >> side1;//input number
cout <<"Enter the value of the angle: ";//sentence
cin >> angle;//input number
cout <<"Enter the value of other side: "; //sentence
cin>> side2;//input number

angle1 = (angle* Pl/180); //turning degree into radiant


distance = pow(side1,2) + pow(side2,2)-(2* side1* side2*cos(angle1));//formula of the law of
cosine
squared = sqrt(distance); // square rooted the number with the square root library function
area = (0.5* side1* side2* sin(angle1)); //formula of area for oblique triangles
cout <<"The distance of it is: "<<squared<<","<<endl;//output
cout <<"The area of the triangle is: "<<area<<",";//output

You might also like