Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- float harmonic_mean(float x, float y);
- #define NUM1 7.90
- #define NUM2 12.123
- int main(void){
- printf("The harmonic mean of %.2f and %.2f is %.2f\n", NUM1, NUM2, harmonic_mean(NUM1, NUM2));
- return 0;
- }
- float harmonic_mean(float x, float y){
- float inverse1, inverse2, average;
- inverse1=1/x;
- inverse2=1/y;
- average=(inverse1+inverse2)/2;
- return 1/average;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement