Can someone check my work for me ,my program wont run

AI Thread Summary
The provided C code snippet aims to gather and analyze voter registration data based on zip codes. It prompts the user to input a zip code, the number of Democratic and Republican voters, and calculates the total number of voters. The code attempts to compute the percentage of Democratic and Republican voters but contains several syntax errors, such as improper use of quotes and missing semicolons. Additionally, there are unclear statements, such as "zipcode, zipcoderep;max amountregisvoters," which do not serve a clear purpose. The code also includes conditional statements to compare the number of Democratic and Republican voters, outputting which party has more registered voters or if they are equal. Proper indentation and use of code formatting are recommended for clarity.
Marta
Messages
4
Reaction score
0
#include<stdio.h>
main()
{
int zipcode,numdem,numrep,sum ;
double perdem, perrep;

While(zipcode!= -1111){
printf("please enter zipcode");
scanf("%d",&zipcode);
printf("please enter numdem)'
scanf("%d",&numdem);
printf("please enter numrep");
scanf("%d",&numrep);
zipcode, zipcoderep;max amountregisvoters
sum=numdem+numrep;district=district+1
perdem=(dem/totalregvoters)*100;
perrep=(rep/totalregvoters)*100;
if(dem<rep)
printf("there are more republicans");
if(dem>rep)
printf("there are more democrats");
if(dem==rep)
printf("the number of democrats and republicans are the same");
printf("\n\n\n\n\n");
}
return0
}
 
Last edited:
Computer science news on Phys.org
When you're posting code, indent and use the
Code:
 tags.
You could start by making sure that:
1. The open and close quotes for everything are where you want them to be.
2. There are semicolons in all appropriate places.

Both of these are common and, in your example rather obvious issues. 

For example:
[QUOTE]
printf("please enter numdem)'
[/QUOTE]

Moreover, what is this line supposed to do?
[QUOTE]
zipcode, zipcoderep;max amountregisvoters
[/QUOTE]
 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...
Back
Top