Question: Make a flowchart of the following program #include #include using namespace std; int main() { int voteCounts[5] = {0}; // array to store vote counts

Make a flowchart of the following program

#include

#include

using namespace std;

int main() {

int voteCounts[5] = {0}; // array to store vote counts for each candidate

int totalVotes = 0; // counter for total number of votes

cout << "Enter the votes (1-5), one per line (enter 0 to end): ";

int vote;

cin >> vote;

while (vote != 0) {

if (vote >= 1 && vote <= 5) { // check if vote is valid

voteCounts[vote -

1]++; // increment vote count for corresponding candidate

totalVotes++; // increment total vote count

}

cin >> vote; // read in next vote

}

// calculate and display results

cout << "Results: ";

for (int i = 0; i < 5; i++) {

int candidateNumber = i + 1;

double percentage = (double)voteCounts[i] / totalVotes * 100;

cout << "Candidate " << candidateNumber << ": " << voteCounts[i]

<< " votes (" << fixed << setprecision(2) << percentage << "%)"

<< endl;

}

cout << "Total votes: " << totalVotes << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a flowchart for the given C voting program follow these steps Step 1 Start Start Begin fl... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!