Saturday 29 April 2023

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 5

 5. Accept two numbers and print arithmetic and harmonic mean of the two numbers (Hint: AM=

(a+b)/2 , HM = ab/(a+b) )


#include<stdio.h>
#include<conio.h>

void main()
{
 int a,b;
 float am,hm;
 clrscr();

 printf("\nFinding the arthmatic mean and harmonic mean:");
 printf("\nEnter the 2 nos:");
 printf("\nEnter the first no:");
 scanf("%d",&a);
 printf("\nEnter the second no:");
 scanf("%d",&b);

 am=(a+b)/2;
 printf("\nArthmatic mean:%f",am);

 hm=a*b/(a+b);
 printf("\nHarmonial mean:%f",hm);

 getch();
}


/*

Finding the arthmatic mean and harmonic mean:                                  
Enter the 2 nos:                                                               
Enter the first no:                                                            
4                                                                              
                                                                               
Enter the second no:                                                           
5                                                                              
                                                                               
Arthmatic mean:4.000000                                                        
Harmonial mean:2.000000                                                        
*/

No comments:

Post a Comment

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...