*/ #include // Global content const int MAX_PARTIES = 2; int party1 = 0; char party1Name[] = "SeaWeed"; int pa

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

*/ #include // Global content const int MAX_PARTIES = 2; int party1 = 0; char party1Name[] = "SeaWeed"; int pa

Post by answerhappygod »

*/#include <stdio.h>// Global contentconst int MAX_PARTIES = 2;int party1 = 0;char party1Name[] = "SeaWeed";int party2 = 0;char party2Name[] = "Aqua";// Function ProtoTypes - Needed for Array of Functionsvoid voteParty1();void voteParty2();void (*partyList[MAX_PARTIES])() = { voteParty1,voteParty2 };// Function Definitionsvoid voteParty2() {party2++;printf("Thank you for voting for the %sParty.\n",party1Name);}void voteParty1() {party1 = party1++; // Bad Syntax supported by Microsoftprintf("Your vote for the %s Party is muchappreciated.\n",party2Name);}void results() {printf("\n%s party has %d vote(s). \n", party1Name, party1);printf("%s party has %d vote(s). \n", party2Name, party2);}//TODO Create the countTYourVote method here/**Main processing*/int main(){
unsigned int choice;while (true) {printf("Enter 1 for %s party\n",party1Name);printf("Enter 2 for %s party\n",party2Name);puts("Enter 0 to Exit");printf("Enter Choice:");scanf("%d",&choice);if (choice > MAX_PARTIES) {continue;}if (choice == 0) {break;}--choice; // adjust index for alignmentcountYourVote(partyList[choice]);}results();}
The included program counts votes but isincomplete. Complete the included program. It needs thefollowing:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply