Question

In: Computer Science

Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each...

Code should be Written in C

  1. Using initialization lists, create 5 one-dimensional arrays, one for each of these:
  • hold the names of the people running in the election
  • hold the names of the subdivision
  • hold the vote counts in the Brampton subdivision for each candidate
  • hold the vote counts in the Pickering subdivision for each candidate
  • hold the vote counts in the Markham subdivision for each candidate

Use the data from the example below.

  1. Your C program should take the data in the arrays and produce the output below, neatly formatted as shown:

Candidates                            Subdivisions                 Totals

                             Brampton  Pickering Markham        

Aubrey                     600            800          800            2200

Blake 700            700          600            2000

Chubbs 800           700          800           etc

Oliver 400            450         300             

Zamier 900            900       900            

Totals                     3400            etc                              etc

Solutions

Expert Solution

The answer to this question is as follows:

#include<stdio.h>
int main() {
//Declaring the variables and initializing the values
char* names[5]={"Aubrey","Blake","Chubbs","Oliver","Zamier"};
char* subdivisions[3]={"Brampton","Pickering","Markham"};
int vote_Brampton[]={600,700,800,400,900};
int vote_Pickering[]={800,700,700,450,900};
int vote_Markham[]={800,600,800,300,900};
int total1=0,total2=0,total3=0;
printf("Candiates\t\t\t\t\tSubdivisions\t\t\t\t\t\t\t\tTotals\n");
for(int i=0;i<3;i++)
{
printf("\t\t\t%s",subdivisions[i]);
}
printf("\n");
for(int i=0;i<5;i++)
{
  
printf("%s\t\t\t%d\t\t\t\t%d\t\t\t\t\t%d\t\t\t\t\t%d\n",names[i],vote_Brampton[i],vote_Pickering[i]
,vote_Markham[i],vote_Brampton[i]+vote_Pickering[i]
+vote_Markham[i]);
total1+=vote_Brampton[i];
total2+=vote_Pickering[i];
total3+=vote_Markham[i];
}
printf("Totals\t\t\t%d\t\t\t%d\t\t\t\t%d",total1,total2,total3);
}


Related Solutions

Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each...
Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each of these: hold the names of the people running in the election hold the names of the subdivision hold the vote counts in the Brampton subdivision for each candidate hold the vote counts in the Pickering subdivision for each candidate hold the vote counts in the Markham subdivision for each candidate Use the data from the example below. * Your C program should take...
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 2: Find the largest value of each row of a 2D array             (filename: FindLargestValues.java) Write a method with the following header to return an array of integer values which are the largest values from each row of a 2D array of integer values public static int[] largestValues(int[][] num) For example, if...
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2....
java by using Scite Objectives: 1. Create one-dimensional arrays and two-dimensional arrays to solve problems 2. Pass arrays to method and return an array from a method Problem 1: Find the average of an array of numbers (filename: FindAverage.java) Write two overloaded methods with the following headers to find the average of an array of integer values and an array of double values: public static double average(int[] num) public static double average(double[] num) In the main method, first create an...
PROBLEM: Write a C program that will produce the EXACT output shown below. Using initialization lists,...
PROBLEM: Write a C program that will produce the EXACT output shown below. Using initialization lists, create 5 one-dimensional arrays, one for each of these: hold the names of the people running in the election (see note below) hold the names of the subdivision (see note below) hold the vote counts in the Aberdeen subdivision for each candidate hold the vote counts in the Brock subdivision for each candidate hold the vote counts in the Sahali subdivision for each candidate...
The code should be written in c++. It should be in only OpenGL // ***** ONLY...
The code should be written in c++. It should be in only OpenGL // ***** ONLY OpenGL PLEASE ******// write a program snippet that accepts the coordinates of the vertices of a rectangle centered around the origin, with edges that are parallel to the X and Y axes, and with aspect ratio W and converts it into a rectangle centered around the origin with aspect ratio of 1/W. The program has to figure W from the given points. You MUST...
Code should be written in C++ using Visual Studios Community This requires several classes to interact...
Code should be written in C++ using Visual Studios Community This requires several classes to interact with each other. Two class aggregations are formed. The program will simulate a police officer giving out tickets for parked cars whose meters have expired. You must include both a header file and an implementation file for each class. Car class (include Car.h and Car.cpp) Contains the information about a car. Contains data members for the following String make String model String color String...
Code in C++. Using ONE of the following themes to create a class and demonstrate the...
Code in C++. Using ONE of the following themes to create a class and demonstrate the idea. Use this to create a solution (two ADTs and a driver program) to demonstrate the following concepts. Create a one page summary to describe where you are using each of these concepts. Themes:(PICK ONE) a house has a door a semester has a holiday break a cell phone has a shatterproof case a chair has a cushion Concepts to include: composition separating interface...
Need this C++ code to be modified to work in C, still using 2d arrays... #include...
Need this C++ code to be modified to work in C, still using 2d arrays... #include <iostream> #include <stdlib.h> #include <time.h> using namespace std; //Implementation of main function int main() { srand(time(NULL)); //Declaration of output,result,i,j,k ,figure as integer type and //assign flog with 0 int output[5][5], result[5], i, j, k, figure = 0; //Display statement cout << "The classic BINGO cards contains 25 squares arranged in five vertical" << endl; cout << "columns and five side to side rows. Each...
LEVEL ONE Lists and indexing Create a list x that spans 1 to 100 using 5...
LEVEL ONE Lists and indexing Create a list x that spans 1 to 100 using 5 unit increments.                                 Hint: Use the inline for and range(). Create a list y containing the elements from x that are divisible by 2.                                 Hint: Explore the for … if … statement. Do b. in another manner. Hint: Use , e.g., array() and where() from numpy. LEVEL TWO Arrays in numpy Create an array x that contains a random set of 100 uniform(0,10)...
Code: C++ Write a very general sort method that can sort any type of data arrays/lists....
Code: C++ Write a very general sort method that can sort any type of data arrays/lists. For example, can sort a list of integers in ascending order, a list of integers in descending order, a list of doubles, a list of student objects (with names and scores) in ascending order of names, or in descending order of scores, … You can use any pre-defined sort function or can code your own. Use your favorite language for implementation. If your language...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT