subject

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.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:30
Ihave a singular monitor that is a tv for my computer. recently, i took apart my computer and put it back together. when i put in the hdmi cord and booted the computer to see if it worked, the computer turned on fine but the screen was blue with "hdmi no signal." i've tried everything that doesn't require buying spare parts, any answer is appreciated!
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
Martha is designing a single-player game. her manager suggests that she plan the design to incorporate future modifications. which principle of game design relates to planning for future modifications?
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
"gps interaction and cognitive process" respond to the following: imagine that you have been asked to design a gps product that will have voice recognition and bluetooth capability. discuss and conceptualize a user interaction model. predict two (2) problems that may arise in gps products with voice recognition and bluetooth capability. recommend solutions for each of these issues. attention is one of the six cognition processes. when attention is applied to a design, the goal is to make it easier for the end user to quickly locate where he / she should type information on the computer or mobile device screen. compare and contrast how the google search engine and the microsoft bing search engine employ the attention cognition process. provide your opinion as to which search engine better employs the attention cognition process and explain why.
Answers: 3
You know the right answer?
Write a program that allows the user to enter the last names of five candidates in a local election...
Questions
Questions on the website: 13722363