In: Computer Science
Code should be Written in C
Use the data from the example below.
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
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);
}