I'm trying to make a program that calculates how many states you need to win. I have the main part of it done but now I'm trying to make a FOR loop that basically checks if the sum of how many votes you have now plus the number of votes the state has is greater than 270, the number to win. After that I'm trying to print that you will win if you win this state. At the end it will count and print out how many ways you can win. This what I have so far but it doesn't say that name of that States when I call them, and it also doesn't give me a 1, 2, or 3 number for how many ways you can win, just a large number that I'm not storing.
Can anyone help me?
#include <stdio.h>
int main(void){
//Initialize your variables
int current_votes, num_votes_1, num_votes_2, x;
char name_state_1, name_state_2;
//ask the user for the current number of electoral votes their candidate has
printf("How many electoral votes has your candidate won?\n");
scanf("%d", ¤t_votes);
//Now ask for the first state in contention
printf("What is the name of the first state in contention?\n");
scanf("%s", &name_state_1);
//now ask hiw many electoral votes the first state has
printf("How many electoral votes does it have?\n");
scanf("%d", &num_votes_1);
//now ask for the second state in contention
printf("What's the name of the second state in contention?\n");
scanf("%s", &name_state_2);
//now ask how many electoral votes the second state has
printf("How many electoral votes does it have?\n");
scanf("%d", &num_votes_2);
//Now here's the formula that checks to see if you win in each state
//and counts how many ways you can win
for(x = 0; x < 3; x++) {
if(current_votes + num_votes_1 >= 270);
printf("Your candidate wins if he/she wins %s", &name_state_1);
x++;
if(current_votes + num_votes_2 >= 270);
printf("Your candidate wins if he/she wins %s", &name_state_2);
x++;
if(current_votes + num_votes_1 + num_votes_2 >= 270);
printf("your candidate wins if he/she wins %s", &name_state_1, &name_state_2);
x++;
}
//now call to tell how many ways the candidate can win overall
printf("your candidate can win %d ways", &x);
return 0;
}
name_state_1andname_state_2aschararrays.