-1

This is my syntax. I'm trying to display an average out of the values. It keeps giving me an error that says: error C2064: term does not evaluate to a function.

Here is my code:

#include <iostream.h>

int main()

{
  double value;
  double sumofvalue = 0;
  int numberofvalues = 0;
  const int sentinel = 0;
  while(value!=sentinel){
    cout << "Enter a value (0 to quit): ";
    cin >> value;
    numberofvalues++;
    sumofvalue+=value;
  }
  cout << "Average is "((sumofvalue)/(numberofvalues));

  return 0;
}
Robᵩ
  • 163,533
  • 20
  • 239
  • 308
masonc15
  • 1,043
  • 2
  • 12
  • 19
  • it's also important to note that the floating point arithmetic often gives unespected result, that math operation is probably not exactly what you are looking for. – user1797612 Dec 11 '12 at 17:47
  • 4
    `` hasn't been correct for 15 years or so. You may be using an archaic compiler or textbook. – Robᵩ Dec 11 '12 at 17:50
  • 1
    One problem is you never initialized value. So the while () may never enter depending on what random value is on the stack where value is located. – drescherjm Dec 11 '12 at 17:51

1 Answers1

15

You are missing << in

cout << "Average is " << ((sumofvalue)/(numberofvalues));
                      ^^ HERE
NPE
  • 486,780
  • 108
  • 951
  • 1,012