Darned Harmonic Mean!

This is a discussion on Darned Harmonic Mean! within the C++ Programming forums, part of the General Programming Boards category; Yes, I know I'm a nitwit. Let's get that out of the way. I'm trying to code a program that ...

  1. #1
    OHNOES! A PURPLE ZOMBIE! Sennet's Avatar
    Join Date
    Sep 2005
    Posts
    20

    Angry Darned Harmonic Mean!

    Yes, I know I'm a nitwit. Let's get that out of the way.

    I'm trying to code a program that calculates the arithmetic, geometric, and harmonic means of numbers.

    Thing is, I can't figure the harmonic mean out. I've got the arithmetic and geometric parts worked out, but the harmonic is giving me trouble.

    Any ideas? Any at all?

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    For this to work all numbers of n[] have to be positive:

    Code:
    int n[3] = {2, 3, 4};
    int d = 2;
    
    float mean = d/((1/n[0])+(1/n[1])+(1/n[2]));
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  3. #3
    OHNOES! A PURPLE ZOMBIE! Sennet's Avatar
    Join Date
    Sep 2005
    Posts
    20
    Quote Originally Posted by durban
    For this to work all numbers of n[] have to be positive:

    Code:
    int n[3] = {2, 3, 4};
    int d = 2;
    
    float mean = d/((1/n[0])+(1/n[1])+(1/n[2]));
    ...Jigga what? I'm sorry, but I'm just a beginning programmer. This not only uses code that I haven't learned yet, but it codes the numbers into the program. I probably should have specified that the program needs to accept an unspecified number of integers from the user.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Average, Geo and Harmonic mean calcl
    By beone2 in forum C Programming
    Replies: 4
    Last Post: 06-24-2009, 06:59 PM
  2. Help with program harmonic series
    By ramayana in forum C Programming
    Replies: 4
    Last Post: 12-15-2005, 10:02 AM
  3. Darned Blinking Cursor
    By VOX in forum C Programming
    Replies: 18
    Last Post: 11-23-2004, 06:36 PM
  4. darned powerpoint
    By Waldo2k2 in forum Tech Board
    Replies: 4
    Last Post: 12-17-2003, 10:39 AM
  5. harmonic mean
    By curlious in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2002, 04:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21