Besides the usual #denne and #include statements, also #include . Inside main(),
ID: 3744975 • Letter: B
Question
Besides the usual #denne and #include statements, also #include . Inside main(), declare all your variables (floating-point and appropriately-named). Then, with "user friendly" language (use good printf prompts), prompt the user to enter the lengths of the two sides of a right triangle. Use scanf to read these values as the triangle's (floating-point) base and height. Next, perform two calculations: 1. Compute the area of the right triangle. 2.Compute the hypotenuse of the right triangle. Note that the statement "y sqrt (arg);" puts the square root of arg into variable y. You had to #include because that's where the "sqrt" function is defined. We'll discuss functions later. Finally, print both results in a "user-friendly report".Explanation / Answer
#include <stdio.h>
#include <math.h>
int main()
{
float a, b,hypotence,y;
float ar;
printf("Enter height and width of the given triangle: ");
scanf("%f%f", &a, &b);
ar = 0.5 * a * b;
printf("Area of right angled triangle is: %f", ar);
y=sqrt((a*a)+(b*b));
printf("length of hypotence is: %f",y);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.