array help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
using namespace std;
int main (){
double scores [6] = {10, 22, 13, 99, 4, 5};
double total;
for (int i = 0; i < 6; i++){
cout <<scores[i] <<" ";
}
total += scores[i];
cout <<total<<endl;
system("PAUSE");
return 0;
}
|
Need to add all these numbers together, my total+= scores doesn't seem to be working..
Works now! :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
using namespace std;
int main (){
double scores [6] = {10, 22, 13, 99, 4, 5};
double total;
for (int i = 0; i < 6; i++){
cout <<scores[i] <<" ";
total += scores[i];
}
cout <<"Total = " << total<<endl;
system("PAUSE");
return 0;
}
|
Thanks man! :D
Topic archived. No new replies allowed.