C++ program to find Average() of AGE and WEIGHT of two students using function overloading

#include <iostream>
#include <math.h>
using namespace std;
float Average(int age1,int age2)
{
    return (age1+age2)/2.0;
}

float Average(float weight1,float weight2)
{
    return (weight1+weight2)/2.0;
}

int main()
{
    int a1,a2;
    float w1,w2;
    cout<<"Enter ages of two students: ";
    cin>>a1>>a2;
    cout<<"Enter weights of two students: ";
    cin>>w1>>w2;
    cout<<endl<<"average of age is "<<Average(a1,a2);
    cout<<endl<<"average of weight is "<<Average(w1,w2);
    return 0;
}

No comments:

Post a Comment