The goal of this assignment is to ask the user how many states they want to compare, collect the data on state name and electoral votes in that state
compare it to the highest state electoral votes, (or if it is the first state, make it the highest) and print out the state with the highest electoral votes, the amount of votes,
and how much it exceeds the average of the other states electoral votes. Here is a sample run:
How many states are you entering?
4
Enter the state name and electoral votes for state 1:
Michigan 11
Enter the state name and electoral votes for state 2:
Florida 28
Enter the state name and electoral votes for state 3:
California 55
Enter the state name and electoral votes for state 4:
Northcarolina 15
Response:
California with 55 is the largest. It exceeds the others’
average by 37.Currently when I enter "Michigan 11" it prints :
Enter the state name and electoral votes for state 2
Enter the state name and electoral votes for state 3
Enter the state name and electoral votes for state 4
without letting me read in the values. I looked over it for an hour or so and checked out a few of my professor's example programs but I cannot find the solution to this error.

:wallbash:

Any assistance would be great

Code
#include <stdio.h>
int main() {
int i, state,electoral_votes=3,num_states;
int greatest_state, greatest_electoral=2, losertally=0, loseravg, avg_diff;
printf("how many states are you entering?\n");
scanf("%d", &num_states);
for (i=1;i<=num_states;i++) {
printf("Enter the state name and electoral votes for state %d\n",i);
scanf("%d",&state);
scanf("%d",&electoral_votes);
if (electoral_votes>greatest_electoral){
losertally+=greatest_electoral;
greatest_electoral=electoral_votes;
greatest_state=state;}
else
losertally+=electoral_votes;
}
loseravg=losertally/num_states;
avg_diff=greatest_electoral-loseravg;
printf("%d with %d is the largest. It exceeds the other's average by %d.\n",greatest_state,greatest_electoral,avg_diff);
system("pause");
return 0;
}