C++ float value average

Description

C++ float value average

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    float fValue1;
    float fValue2;
    float fValue3;

    cout << "Enter three floats:\n";

    cout << "f1 - ";
    cin  >> fValue1;/*from   www.  j av a  2s.co m*/

    cout << "f2 - ";
    cin  >> fValue2;

    cout << "f3 - ";
    cin  >> fValue3;

    cout << "n1/3 + n2/3 + n3/3 = " << fValue1/3 + fValue2/3 + fValue3/3 << "\n";

    // now the ratio of three sums
    cout << "(n1 + n2 + n3)/3   = " << (fValue1 + fValue2 + fValue3) / 3 << "\n";

    return 0;
}



PreviousNext

Related