average
as a "Mastery Check" for chapter 1 of a tutorial
i needed to make a program that can calculate the average of 5 values.
after doing this (easypeasylemonsqueezy) i tried to make a program that can calculate the average of more values (you can enter te amount of values).
the result was this.
the only problem is it doesn't work
can someone explain how to make it work?
i needed to make a program that can calculate the average of 5 values.
after doing this (easypeasylemonsqueezy) i tried to make a program that can calculate the average of more values (you can enter te amount of values).
the result was this.
the only problem is it doesn't work
can someone explain how to make it work?
#include <iostream>
using namespace std;
int main ()
{
int amount;
double result, value, tellen;
result = 0;
cout << "put in the amount of values you want the average of: ";
cin >> amount;
cout << endl;
for(tellen = 1; tellen <= amount; tellen++)
{
cout <<"Put in the " << amount << " number.";
cin >> value;
cout <<endl;
result + value = result; //what is wrong with this line?
}
cout << "The average is " << result/amount <<"." <<endl;
system ("pause");
return 0;
}
using namespace std;
int main ()
{
int amount;
double result, value, tellen;
result = 0;
cout << "put in the amount of values you want the average of: ";
cin >> amount;
cout << endl;
for(tellen = 1; tellen <= amount; tellen++)
{
cout <<"Put in the " << amount << " number.";
cin >> value;
cout <<endl;
result + value = result; //what is wrong with this line?
}
cout << "The average is " << result/amount <<"." <<endl;
system ("pause");
return 0;
}


