Ok, well I attempted another exercise in the book. It was to 'Write a program that reads in a sequence of positive numbers and prints out the total and average value. The end of the sequence should be signalled by entering -1'.
This is what I came up with:
Code:
#include <iostream.h>
int main()
{
int x, y = 0, z = 0;
while(x != -1)
{
x = 0;
cout << "Enter a number: ";
cin >> x;
z++;
y = x + y;
}
y = y + 1;
cout << "The average of those numbers is " << y / z;
}
Only when I enter -1 it messes up and says an error log is being created
Thanks if you can help
-Marlon