i want to write a c++(console) programme for a voting system that accepts names of candidates and the votes they had and sort these votes in descending order to show the winner. how do i go about it. thanks.
this is the what i have been able to do so far.

#include <isotream.h>
 char names[5][5];   // five names of candidates and 5 constitutes
 cout<<"enter the names"<<endl;
for (int m=0; m<5; m++)
      {
           cin>>names[m];
      }

>>i'm around for more clarificaions
Ok, then lets see the code YOU have written.

#include <iostream.h>
char names[5][10];
cout<<"enter names of candidates"<<endl;
for (int m=0; m<5; m++)
     {
          cin>>names[m];
     }

> #include <iostream.h> I disagree: Use #include <iostream> instead

> char names[5][10]; What happens when a name is longer then 10 chars? Use a string instead

> cout<<"enter names of candidates"<<endl; This will result in "undefined identifier 'cout'" error. Use std::cout and std::endl or add 'using namespace std' before main. Speaking of which: where is your int main() ?

> cin>>names[m]; Same problem as with cout and endl. Besides: what happens when a name has a space in it?

Next time you post, please use code tags.

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.