Thread: Help with code

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    Help with code

    Need to write a program that will read in 3 positive double values as the three sides of a triangle. echo the input and then output the perimeter and area of that triangle.
    Formula for computing the area of a triangle is given (must include math.h):
    area = sqrt( s * (s - a) * (s - b) * (s - c) )

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    What sort of help?

    Reading in some values?
    Printing values?
    Doing a calculation - well you almost have that, all it needs is a ; at the end.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    2
    i need to make that information into a code so i can get an output for it.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Yes, but what do you KNOW already?

    Code:
    int main ( ) {
      printf("hello world\n");
    }
    
    int main ( ) {
      int numCabbages;
      printf("How many cabbages do you have?\n");
      scanf("%d", &numCabbages);
    }
    And so on.

    The second is basically half-way to your answer anyway.
    That is, doing the "question and answer" code to allow the user to type in the parameter values for your function.

    If you're not willing to make a stab at inputting values for s,a,b,c then you should probably drop the course.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-10-2010, 11:28 AM
  2. Replies: 14
    Last Post: 04-01-2008, 02:23 AM
  3. producing c/c++ code from flowcharts,pseudo code , algorithims
    By rohit83.ken in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2008, 07:09 AM
  4. Having trouble translating psudeo-code to real-code.
    By Lithorien in forum C++ Programming
    Replies: 13
    Last Post: 10-05-2004, 07:51 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM