The results from the mayor's race have been reported by each precinct as follows: P A B C D 1 192 48 206 37 2 147 90 312 21 3 186 12 121 38 Write a program to do the following: i. Display the table with appropriate headings for the rows and columns. ii. Compute and display the total number of votes received by each candidate and the percent of the total votes cast.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.2: Formatting Numbers For Program Output
Problem 10E
icon
Related questions
Question

1. The results from the mayor's race have been reported by each precinct as follows:

P A    B   C    D
1 192 48 206 37
2 147 90 312 21
3 186 12 121 38
Write a program to do the following:

i. Display the table with appropriate headings for the rows and columns.
ii. Compute and display the total number of votes received by each candidate and
the percent of the total votes cast.

2. Write a program in C++ to display the sum of the series [ 9 + 99 + 999 + 9999 ...].
Test Data :
Input the number or terms:5
Expected Output :
9 99 999 9999 99999
The sum of the series = 111105

3. Write a program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms.
Test Data :
Input the number of terms : 5
Expected Output :
1 + 11 + 111 + 1111 + 11111
The Sum is : 12345

4. Write a C program to create a new array after replacing all the values 5 with 0 shifting all
zeros to right direction.
Expected Output:
Elements in original array are: 1, 2, 0, 3, 5, 7, 0, 9, 11, 5
Elements in new array are: 1, 2, 0, 3, 7, 0, 9, 11, 0,

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Binary numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr