Length of diagonal of a parallelogram using adjacent sides and angle between them | C ++ program to find length Of diagonal of a parallelogram Using sides and angle between them . ; Function to return the length Of diagonal of a parallelogram using sides and angle between them . ; Driver Code ; Given sides ; Given angle ; Function call ; Print the final answer
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define PI  3.147 NEW_LINE double Length_Diagonal ( int a , int b , double theta ) { double diagonal = sqrt ( ( pow ( a , 2 ) + pow ( b , 2 ) ) - 2 * a * b * cos ( theta * ( PI / 180 ) ) ) ; return diagonal ; } int main ( ) { int a = 3 ; int b = 5 ; double theta = 45 ; double ans = Length_Diagonal ( a , b , theta ) ; printf ( " % .2f " , ans ) ; }