0

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];
      }

Edited by Nick Evan: Added tags

3
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by Nick Evan
0
#include <iostream.h>
char names[5][10];
cout<<"enter names of candidates"<<endl;
for (int m=0; m<5; m++)
     {
          cin>>names[m];
     }

Edited by Nick Evan: Added code-tags

0

> #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.

Edited by Nick Evan: corrected icode tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.