Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me Finish this code !! C++ Q1.This program calculates if the 3

ID: 3564506 • Letter: C

Question

Can someone help me Finish this code !!
C++ Q1.This program calculates if the 3 lines form a valid right triangle The lines form a valid triangle if a^2+b^2=c^2 where a is the shortest length, b is of intermediate length, and c is the longest length. #include using namespace std; boil isRightTriangle(double s1, double s2, double s3); void sort(double& s1, double& s2, double& s3); int main() { double len1, len2, len3; cout len2 > > len3; sort(len1, len2, 1en3); if ((isRightTriangle(len1, len2, len3)) cout

Explanation / Answer

#include<iostream>
using namespace std;

bool isRightTriangle(double s1, double s2, double s3);
void sort(double& s1,double& s2,double& s3);

int main()
{
double len1, len2, len3;
cout <<"Enter the lengths of 3 sides " << endl;
cin >> len1 >> len2 >> len3;
sort(len1,len2,len3);
if(isRightTriangle(len1,len2,len3))
cout <<"Lengths entered form a valid triangle"<< endl;
else
cout <<"Lengths entered do not form a valid triangle"<< endl;
return 0;
}

void sort(double& s1,double& s2,double& s3)
{
if(s1>s2) { double temp = s1; s1 = s2; s2 = temp; }
if(s2>s3) { double temp = s2; s2 = s3; s3 = temp; }
if(s1>s2) { double temp = s1; s1 = s2; s2 = temp; }
}

bool isRightTriangle(double s1, double s2, double s3)
{
return (s1*s1+s2*s2== s3*s3);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote