4/01/2009

C++ Program To Calculate The Average Of 3 Numbers


/* C++ Program To Calculate The Average Of 3 Numbers */

#include <iostream>

using namespace std;

void total(int a,int b, int c)
{
    float sum=0;
    sum=a+b+c;
        cout<<"Sum Of Numbers:"<<sum<<endl;
}
void average(int a,int b, int c)
{
    float avg=(a+b+c)/3.0;
        cout<<"Average Of Numbers:"<<avg<<endl;
}
int main()
{
    float a, b, c;
      cout<<"Enter Three Numbers:"<<endl;
        cin>>a>>b>>c;
    total(a,b,c);
    average(a,b,c);

    return 0;
 }
Out Put:
Enter Three Numbers:
10
20
30
Sum Of Numbers:60
Average Of Numbers:20

No comments:

Post a Comment