Okay, hello, my code works all most according to the standards, but i can't seem to figure out how to get the total out of the loop and insert it into another loop. Basically, I can't get the percentage of the votes from each candidate because the total stays as 0 in the loop. I've been at this for days & can't figure it out. Please help asap, anyways, here is the code:
Code:
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()

{
	string name[10];
	int votes[20];
	int total = 0;
	double percent[10];
	int m, i, j, sum = 0, max = 0;

	cout << "Please enter 5 candidates followed by the votes they recieved here:\n";

	for(i = 0; i < 5; i++)
	{
		cin >> name[i];
		cin >> votes[i];
		total = total + votes[i];
	}

	for (j = 0; j < 5; j++)
			percent[j] = votes[j]/ total * 100;


	cout << left << setw(10) << "Canditates" << right << setw(15) << "Votes" << setw(12) << "Percent" << endl;

	cout << setprecision(2);

	for(i=0; i <5; i++)
		cout << left << setw(10) << name[i] << right << setw(15) << votes[i] << setw(12) << percent[i] << endl;

	cout << left << setw(10) << "Total:" << right << setw(15) << total << endl;

	m = 0;

	for (i = 0; i < 5; i++)
	{
		if (votes[i] > m)
		{
			m = votes[i];
			max = i;
		}
			
	}

	cout << "The winner of the election is: " << name[max] << endl;

	return 0;
}