C Program arithmetic and harmonic mean of two numbers - IProgramX

Q.  Accept two number and print arithmetic and harmonic mean of the two numbers.


Program

#include <stdio.h>
int main()
{
   int a,b;
   float arithmetic_mean,harmonic_mean;
   printf("enter two no. A and B :-");
   scanf("%d%d",&a,&b);
   arithmetic_mean = (a+b) /2;
   harmonic_mean = (a*b) / (a+b);
   printf("arithmetic mean = %f and harmonic mean = %f",arithmetic_mean,harmonic_mean);
}

Output:

enter two no. A and B :- 6 3
arithmetic mean = 4.000000 and harmonic mean = 2.000000

Post a Comment

0 Comments