Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Compute Average

    int a, b, c, d, sum, average;

    cout << "Input the 1st number: ";
    cin >> a;
    cout << "Input the 2nd number: ";
    cin >> b;
    cout << "Input the 3rd number: ";
    cin >> c;
    cout << "Input the 4th number: ";
    cin >> d;

    sum = a+b+c+d;
    average = sum/4;

    cout << "The average is: " << average << endl;
 
PREVIOUS NEXT
Tagged: #Compute #Average
ADD COMMENT
Topic
Name
5+4 =