Study Resources
Main Menu
by School
by Textbook
by Literature Title
Study Guides
Infographics
by Subject
Expert Tutors
Contributing
Main Menu
Earn Free Access
Upload Documents
Refer Your Friends
Earn Money
Become a Tutor
Scholarships
For Educators
Log in
Sign up
Find
Study Resources
by School
by Textbook
by Literature Title
Study Guides
Infographics
by Subject
Ask
Expert Tutors
You can ask
!
Earn by
Contributing
Earn Free Access
Learn More >
Upload Documents
Refer Your Friends
Earn Money
Become a Tutor
Scholarships
Learn More >
Are you an educator?
Log in
Sign up
Bahria University, Lahore
COMPUTER S
COMPUTER S CSC-112
OOP Lab Q5.txt - #include <iostream>#include<string>\/using namespace std\/class candidate\/public string name int vote\/void outputElection(candidate arr
OOP Lab Q5.txt - #include <iostream>#include<string>/using...
School
Bahria University, Lahore
Course Title
COMPUTER S CSC-112
Uploaded By
Syed_Faizan_Zaidi
Pages
2
This
preview
shows page
1 - 2
out of
2
pages.
//#include <iostream>
//#include<string>
//using namespace std;
//
//class candidate{
//public:
//
string name;
//
int vote;
//};
//
//void outputElection(candidate* arr){
//
int total_vote = 0;
//
for (int i = 0; i<5; i++){
//
//finding total no of votes
//
total_vote = total_vote + arr[i].vote;
//
}
//
//
cout << "result of the election
.............
" << endl;
//
cout << "name of candidate" << "\t" << "vote received" << "\t" <<
"percentage" << endl;
//
for (int i = 0; i<5; i++){
//
cout << arr[i].name << "\t\t\t";
//
cout << arr[i].vote << "\t\t";
//
cout << (arr[i].vote * 100) / total_vote << "%" << endl;
//
}
//
//
int max = INT_MIN, count = 0;
//
int index[5] = { 0 };
//
//
for (int i = 0; i<5; i++){
//
if (arr[i].vote>max){
//
max = arr[i].vote;
//
}
//
}
//
//
for (int i = 0; i<5; i++){
//
if (arr[i].vote == max){
You've reached the end of your free preview.
Want to read both pages?
TERM
Fall '18
PROFESSOR
Zia Ul Rehman
TAGS
Carriage return,
int total,
votes,
int vote
Share this link with a friend:
Copied!