Slip 4 - A) Write a C program to accept two numbers and print arithmetic and harmonic mean of the two numbers (Hint: AM= (a+b)/2 ,HM = ab/(a+b) )

Solution:


#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);
}

Post a Comment

0 Comments