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

Click For Summary
SUMMARY

The forum discussion addresses a C programming issue where the user's code fails to run due to syntax errors and logical mistakes. Key problems identified include incorrect use of quotes in the printf function, missing semicolons, and unclear variable declarations such as "zipcode, zipcoderep;max amountregisvoters". The discussion emphasizes the importance of proper syntax and code structure to ensure successful compilation and execution.

PREREQUISITES
  • Understanding of C programming syntax
  • Familiarity with variable declaration and initialization
  • Knowledge of control structures in C (e.g., loops and conditionals)
  • Experience with debugging common programming errors
NEXT STEPS
  • Review C programming syntax rules
  • Learn about debugging techniques in C
  • Explore the use of printf and scanf functions in detail
  • Study variable scope and lifetime in C programming
USEFUL FOR

This discussion is beneficial for beginner to intermediate C programmers, software developers troubleshooting code, and anyone looking to improve their debugging skills in C.

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]
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
47
Views
6K
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K