Hi ,i am so happy that you guys help me out for my previous problem concerning about coding programming.Right now i am stuck with my Candidate programme where i need to Cout the total result for the winning candidate.

The question is : There is 5 candiate runing for little city where the population is 2000 people.I allready write the programme but i dont how to Cout the final result for the winning candidate .SO please can you help me out

#include <iostream>
using namespace std;
int main ()
{

	const int candidatenumber=5;
	const int votenumber=10;

	int candidate[candidatenumber]={0};
	int vote[votenumber];

	for(int i=0;i<votenumber;i++)
	{
		cout<<"Enter your vote 1 to 5 :"<<endl;
		cin>>vote[i];
		candidate[vote[i]]++;
	}


	return 0;
}

If your problem is to display the number of votes each candidate got, you'll use a loop similar to your input loop, only output each element of the candidate array. If you want to only show which candidate won (got the most votes), you'll have to go through the candidate array keeping track of the index that holds the largest value.

Food for thought: What do you do in case of a tie?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.