Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,769 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,580 people online right now. Registration is fast and FREE... Join Now!




calculating third side of triangle problem (C)

 
Reply to this topicStart new topic

calculating third side of triangle problem (C), I have completed a program for right triangles, but I need help with o

JamieMc103
7 Feb, 2007 - 04:26 PM
Post #1

New D.I.C Head
*

Joined: 7 Feb, 2007
Posts: 2


My Contributions
[
#include <stdio.h>
#include <stdio.h>

int main(void)
{

/*Declare and initialize variables*/
double x1=1, y1=5, x2=4, y2=7,
side_1, side_2, distance;

/*Compute sides of a right triangle. */
side_1 = x2 - x1;
side_2 = y2 -y1;
distance = sqrt(side_1*side_1 + side_2*side_2);

/* Print distance. */
printf("the distance between the two points is "
"%5.2f \n", distance);

/*Exit program. */

return 0;

}

]


The other half of the program must compute the third side of non-right triangles.

These are my instructions, and I am VERY lost sad.gif .

• Declare PI 3.14159 as constants using a preprocessor directive.
• Use the cos( ), sqrt( ), and pow( ) functions. This means that you need to include math.h.
• Declare ALL variables use in the calculations as double.
• Use descriptive variable names.
• Prompt for and enter a value for length of side b, length of side c, and size of angle a in degrees.
You do not need to test the input data for errors in this assignment.
But, keep in mind: 0 < size of angle a < 180 degrees.
• Calculate radians and length of side a.
• Display the values of the length of side b, length of side c, and size of angle a in degrees with
appropriate labels and NO decimal places.
Display the values for length of side a with THREE decimal places in a sentence.
Leave only one space before and after the numeric output.
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Calculating Third Side Of Triangle Problem (C)
7 Feb, 2007 - 05:34 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
use [code ][ /code] tags around any and all code segments (without the spaces).
do not post in the lounge or elsewhere to get help on a thread in another forum.

Please read the rules, links in my signature.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 06:28AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month