C++ int type Average

Description

C++ int type Average

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

int main(int nNumberofArgs, char* pszArgs[])
{
    int nValue1;//from w w w.ja  v a  2s  .  c o m
    int nValue2;
    int nValue3;

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

    cout << "n1 - ";
    cin  >> nValue1;

    cout << "n2 - ";
    cin  >> nValue2;

    cout << "n3 - ";
    cin  >> nValue3;

    cout << "n1/3 + n2/3 + n3/3 = " << nValue1/3 + nValue2/3 + nValue3/3 << "\n";

    // now the ratio of three sums
    cout << "(n1 + n2 + n3)/3   = " << (nValue1 + nValue2 + nValue3) / 3 << "\n";

    return 0;
}



PreviousNext

Related