I´m suppose to count the votes of 2 candidates and show the result of who won, but when the user tells how many electors there are, the programs only runs half of the times it should. Also, for some reason the questions always appears two times, like if it passes through the loop but doesnt do anything (if n is an odd number, it approaches down.
I´ve also tried to do it using the loop 'for', but I had the same problem
#include<stdin.h>
#include<stdlib.h>
void main()
{
int sumj=0,summ=0,counter=0,n;
char vote;
printf("how many electors are there?\n");
scanf("%d",&n);
do
{
printf("Whats your vote? m for maria j for james\n");
scanf("%c",&vote);
if (vote=='j')
{
sumj++;
}
if (vote=='m')
{
summ++;
}
counter++;
} while (counter<n);
if (sumj>summ)
printf("james won");
if (summ>sumj)
printf("maria won");
if (sumj==summ)
printf("its a tie");
}