Hello, I am extremely new to C++.. following the guidelines of a book I bought, I have knowledge of PHP etc so I know a few things.
Anyway I went ahead of myself and tried to create something using simple arrays. Here's what I got.
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
string average;
int total=0;
int i=0;
int input;
for(i =0; i<3; ++i){
cout<<"Enter A Number:"<<endl;
cin>>average[i];
cout<<" adding: "<<average[i]<<" to "<<total<<endl;
total += average[i];
cout<<" new total: "<<total<<endl;
}
cout<<total<<endl;
cout<<"\nThe average of "<<i<<" numbers is: "<<total/i<<".";
system("pause");
}
My problem is, average[] array is obviously not adding the integer value of what the user enters. How can I convert the input to average[i] from a string to integer so the total is correct? Or better yet, how do I create a Integer specific array?
Thanks in advance for your help. I hope I was clear enough.
-Aaron