Question

2. Write a program that prompts a user to enter the lengths of sides and angles for the two triangles described below. The program should calculate the length of the side of the triangle indicated below. Print the two answers to 3 decimal places onto the console screen Triangle 1 Read in the value of the angle, alpha, and the length, a, of the side indicated in the picture below. Calculate the length of the hypotenuse, c, of this right triangle: Test your program with: alpha 32 a-4.5 Triangle 2 Read in the value of the angle, beta, and the length, a, of the side indicated in the picture below. Calculate the length of the side opposite of the angle, b, of this right triangle: Test your program with: beta -40 a-2.2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* CODE IN C */

#include<stdio.h>
#include<math.h>

int main()
{
   /*Triangle 1*/
   float alpha, a, hypotenuse;
   printf("FOR TRIANGLE 1 ");
   printf("Enter alpha = ");
   scanf("%f", &alpha);
   printf("Enter a = ");
   scanf("%f", &a);
   alpha = alpha * 3.14 / 180;//Convert beta to radians
   hypotenuse = a/sin(alpha);//Assuming a is perpendicular for alpha
   printf("Hypotenuse = %.3f ", hypotenuse);
  
   /*Triangle 2*/
   float beta, b;
   printf("FOR TRIANGLE 2 ");
   printf("Enter beta = ");
   scanf("%f", &beta);
   printf("Enter a = ");
   scanf("%f", &a);
   beta = beta * 3.14 / 180;//Convert beta to radians
   b = tan(beta) * a;//For angle beta, side a is base and side b is the opposite side
   printf("Opposite side of angle beta = %.3f ", b);
   return 0;
}

OUTPUT:
CAUsers Shubham Desktop Untitled1.exe FOR TRIANGLE 1 Enter alpha 32 Enter a4.5 Hypotenuse = 8.496 FOR TRIANGLE 2 Enter beta 4

FOR ANY HELP REACH ME OUT IN COMMENTS

Add a comment
Know the answer?
Add Answer to:
2. Write a program that prompts a user to enter the lengths of sides and angles...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java program that prompts the user to enter a number representing a geometric shape....

    Write a Java program that prompts the user to enter a number representing a geometric shape. Options are 1 for square, 2 for rectangle, and 3 for right triangle. According to the user input, the program will collect either 1, 2 or 3 values from the user representing the lengths of the shape sides. The user is responsible for ensuring the 3 sides of the triangle represent a right triangle. The program will print the perimeter of the shape. Use...

  • Write a C++ program using user defined functions that will read in the lengths of two...

    Write a C++ program using user defined functions that will read in the lengths of two side of a right triangle and then calculate the length of the hypotenuse. The program should do this twice. The program should the following user defined functions: Function readA will read in a value for side A from the user and return it to main. (it will not receive any input data from main) Function readB will read in a value for side B...

  • Find the lengths of the missing sides if side ais opposite angle A, side bis opposite...

    Find the lengths of the missing sides if side ais opposite angle A, side bis opposite angle B, and side c is the hypotenuse Draw a right triangle labeling side a, side b, and hypotenuse, and their corresponding angles. Define the ratio for tan(A) in terms of ab, or what proportion relates the given valu for tan(A) and the defined ratio for tan(A)? How is this proportion solved for a with values for side and sideb, use the Pythagorean Theorem...

  • The "for more practice part" using matlab If the lengths of two sides of a triangle...

    The "for more practice part" using matlab If the lengths of two sides of a triangle and the angle between them are known, the length of the third side can be calculated. Given the lengths of two sides (b and c) of a triangle, and the angle between them alpha in degrees, the third side a is calculated as follows a^2 = b^2 + c^2 - 2b c cos(alpha) White a script thirdside that will prompt the user and read...

  • Using Pythagorean's Theorem, find the hypotenuse if the two sides have a length of 300m and...

    Using Pythagorean's Theorem, find the hypotenuse if the two sides have a length of 300m and 400m (Pythagorean's Theorem states that a^2 + b^2 = c^2, where a and b are the lengths of the sides of a right triangle and c is the length of the side opposite the 90 degree angle).

  • Write the java program: A right triangle can have sides whose lengths are all integers. The...

    Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...

  • Write the java program: A right triangle can have sides whose lengths are all integers. The...

    Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...

  • To use trigonometric functions to find sides and angles of right triangles.

    Learning Goal:To use trigonometric functions to find sides and angles of right triangles.The functions sine, cosine, and tangent are called trigonometric functions (often shortened to "trig functions"). Trigonometric just means "measuring triangles." These functions are called trigonometric because they are used to find the lengths of sides or the measures of angles for right triangles. They can be used, with some effort, to find measures of any triangle, but in this problem we will focus on right triangles. Right triangles...

  • he lengths of the three sides of a triangle (not necessarily a right triangle) are 3.56...

    he lengths of the three sides of a triangle (not necessarily a right triangle) are 3.56 meters, 5.07 meters and 2.09 meters. What is the cosine of the angle opposite the side of length 2.09 meters? cos theta =_________

  • Write a program that prompts the user to enter the sides and their length of a...

    Write a program that prompts the user to enter the sides and their length of a regular polygon and display its area. ****Using c++

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT