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

In summary, this conversation is about a program that asks the user for a zipcode and number of registered Democrats and Republicans. It calculates the percentage of Democrats and Republicans, and determines if there are more Democrats or Republicans in the district. The program also checks for errors in the code.
  • #1
Marta
4
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
  • #2
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]
 
  • #3


It is not appropriate to ask someone to check your work for you. It is important to take responsibility for your own work and ensure that it is correct. You can try debugging your program by checking for any errors or running it through a code checker. Additionally, you can reach out to your instructor or classmates for assistance in troubleshooting the issue.
 

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

1. Why won't my program run?

There could be several reasons why your program won't run. It could be due to a coding error, missing libraries or dependencies, or incorrect input. It's important to carefully review your code and check for any errors or missing components.

2. How can I get someone to check my work?

You can ask a colleague, classmate, or a professional in the field to review your work. There are also online communities and forums where you can post your code and ask for feedback and assistance.

3. What information should I provide when asking someone to check my work?

It's important to provide as much information as possible when asking someone to check your work. This includes your code, any error messages you're receiving, and a description of the problem you're having. The more information you provide, the easier it will be for someone to help you.

4. How can I prevent my program from not running in the future?

To prevent your program from not running in the future, it's important to practice good coding habits such as commenting your code, testing it regularly, and using proper coding conventions. It's also helpful to seek feedback from others and learn from any mistakes you may have made.

5. Should I be worried if my program won't run?

It's normal for programs to have errors and not run properly, especially when you're still learning and developing your skills. Instead of worrying, focus on troubleshooting and finding a solution. Remember to take breaks and ask for help when needed.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
47
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
Back
Top