Flowchart
Code
//Idtisak paopo
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
char ch;
float side_a, side_b, side_c;
do
{
printf("\n This program calculates the longest side of a triangle\n");
printf("based on Pythagorean theorem\n");
printf("a. Run the program \n");
printf("e. Exit the program \n");
ch=getche();
if (ch!='e')
{
printf("\n");
printf("Please enter the 1st side \n");
scanf("%f", &side_a);
printf("Please enter the 2nd side \n");
scanf("%f", &side_b);
if ((side_a>=0)&&(side_b>=0))
{
side_c=sqrt(side_a*side_a+side_b*side_b);
printf("The longest side is %.3f \n",side_c);
}
else
{
printf("Invalid value, please try again\n");
}
}
else
printf("\n BYE! \n");
}
while (ch!='e');
return 0;
}