# Need help with Right Triangle Program

Page 1 of 1

## 2 Replies - 1501 Views - Last Post: 05 May 2014 - 06:39 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=346391&amp;s=fc25b25e7898e2fd987899f14fac1264&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

• New D.I.C Head

Reputation: 0
• Posts: 10
• Joined: 05-May 14

# Need help with Right Triangle Program

Posted 05 May 2014 - 06:27 PM

I made a simple program to compute the lengths of a triangles sides, but when I enter 30 for angle and 10 for hypotenuse I get the opposite side is -9.880316 and the adjacent is 1.542514. Dunno what the issue is.

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

main()
{
float angle;
float hypotenuse;
float opposite;

puts("This program will compute the length of the opposite and adjacent");
puts("sides of a right triangle, given the length of the hypotenuse and");
puts("an angle.");
puts("");

printf("Please input an angle of the triangle. => ");
scanf("%f", &angle);
printf("Please input the length of the hypotenuse. => ");
scanf("%f", &hypotenuse);
puts("");

opposite = sin(angle) * hypotenuse;
adjacent = cos(angle) * hypotenuse;

printf("The length of the opposite side is %f units. \n", opposite);
printf("The length of the adjacent side is %f units. \n", adjacent);
}

```

This post has been edited by jimblumberg: 05 May 2014 - 07:31 PM
Reason for edit:: Fixed code tags

Is This A Good Question/Topic? 0

## Replies To: Need help with Right Triangle Program

### #2 andrewsw

• RequestedRangeNotSatisfiable

Reputation: 6554
• Posts: 26,569
• Joined: 12-December 12

## Re: Need help with Right Triangle Program

Posted 05 May 2014 - 06:35 PM

You are working in degrees but the computer is working in radians.

• New D.I.C Head

Reputation: 0
• Posts: 10
• Joined: 05-May 14

## Re: Need help with Right Triangle Program

Posted 05 May 2014 - 06:39 PM

Ohhhh, that makes much more sense. Thank you.