OOCP1_9

//HiTech Banda //bit.ly/hitechbanda #include <iostream.h> #include <conio.h> void main() { int count[5]={0},vote,spoilt=0,a; char opt='y'; while(opt=='y') { clrscr(); cout<<"\nElection : 5 candidates\n\nVote for candidate no. [1-5] : "; cin>>vote; switch(vote) { case 1: count[0]++; break; case 2: count[1]++; break; case 3: count[2]++; break; case 4: count[3]++; break; case 5: count[4]++; break; default:cout<<"\nSpoilt ballot!"; spoilt++; } cout<<"\nVote again? [y/n] : "; cin>>opt; } clrscr(); for(a=0;a<5;a++) cout<<endl<<"Candidate "<<a+1<<" : "<<count[a]<<" votes"; cout<<"\nSpoilt Votes : "<<spoilt; getch(); }

2 Responses

A best and simple program...thanks for this
@Raghvendra Singh Thank you Raghvendra!
:)

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.