# 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. ## 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. 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]));```

3. 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.