I'm learning to program with arrays and thought I was getting the concept until I executed my program. If someone could point me in the direction of my mistakes I'd really appreciate it.
Code:#include <iostream> #include <string> #include <iomanip> using namespace std; int main() { char name[5][16]; double votes[5]; double percent[5]; int sum; int index; double actualpercent; cout << fixed << showpoint << setprecision(2); cout << "Enter candidate's name and the votes received by the candidate." << endl; for (index = 0; index < 5; index++) cin >> name[index][16] >> votes[index]; cout << endl; sum = 0; for (index = 0; index < 5; index++) sum = sum + votes[index]; actualpercent = 0; for (index = 0; index < 5; index++) actualpercent = (votes[index] / sum) * 100; cout << "Candidate" << setw(5) << "Votes Received" << setw(5) << "% of Total Votes" << endl; for (index = 0; index < 5; index++) cout << name[index][16] << setw(10) << votes[index] << setw(10) << percent[index]; cout << "Total" << setw(10) << sum << endl; return 0; }