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
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
0 Comments