Computers and Technology

Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate's name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. i have this
#include
#include
#include
using namespace std;
int findMax(int votes[]);
void main()
{
int votes[20];
string name[10];
int total=0;
float percent[10];
int m, i, loc;
cout<<"Enter the names of candidates in local election and number of votes:"< for(int i=0;i<5;i++)
{
cin>>name[i];
cin>>votes[i];
}
for(i=0;i<5;i++)
{
total=total+votes[i];
}
for(i=0;i<5;i++)
{
percent[i]=((votes[i]/total)*100);< br /> }
cout<<"Candidate"<<'\t' <<"VotesReceived"<<'\t' <<"% of Total Votes"< cout< for(i=0;i<5;i++)
{
cout< }
cout<<"Total:"< m=findMax(votes);
cout<<"Winner of the election is"< system("pause");
}
int findMax(int votes[])
{
int i, max, loc;
max=votes[0];
for(i=1;i<5;i++)
{
if(votes[i]>max)
{
max=votes[i];
loc=i;
}
}
return loc;
}
But, it is saying that loc is not initialized, and it is also not calculating % of total votes or the winner of the election and I don't what to do to fix it.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:30, lilpeepxliltracy
This technology is used to produce high-quality documents that look good on the computer screen and in print.
Answers: 1
image
Computers and Technology, 22.06.2019 07:30, akluke6059
Events and conditions that happen within an organization that are somewhat easier to deal with when responding to change are called
Answers: 1
image
Computers and Technology, 22.06.2019 10:40, StephiUnicorni
When running anti-virus software , what could be a reason where recipitent is not guaranteed that data being streamed will not get interrupted?
Answers: 1
image
Computers and Technology, 22.06.2019 11:00, najerajulio
What is the foundation for proper monitoring, load balancing and routing in distributed systems
Answers: 3
Do you know the correct answer?
Write a program that allows the user to enter the last names of five candidates in a local election...

Questions in other subjects:

Konu
Mathematics, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
English, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
English, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01
Konu
Mathematics, 15.09.2020 21:01