------------------------------------------------------------------------------
MC logo
Average of Three
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Standards] [Programming Environment] [Hello, World!] [Hello Again, World!] [Identifiers] [Constants] [Average of Three] [Basic Types] [Shortcut Operators] [Increment Operators] [C++ Strings]
av1.cc
#include <iostream>

using namespace std;

int main(void)
{
        // Read the numbers.
        cout << "Enter 3 numbers: ";
        int n1, n2, n3;
        cin >> n1 >> n2 >> n3;

        // Compute the sum and average.
        double sum = n1 + n2 + n3;
        cout << "The mean of " << n1 << " " << n2 << " " << n3 << " "
             << "is " << (double)sum/3 << endl;

        return 0;
}