Source Code:
#include<iostream>
using namespace std;
int main ()
{
int z=1,x,a=0,b=0,c=0,d=0;
cout<<"What is your name?\n1)Ali\n2)Bravo\n3)Kumar\n4)Umair"<<endl;
cout<<"Choose any answer by pressing only 1,2,3,4 (20 times): "<<endl;
while(z<=20)
{
cin>>x;
if(x==1){
a=a+1;
}
if(x==2){
b=b+1;
}
if(x==3){
c=c+1;
}
if(x==4){
d=d+1;
}
z++;
}
cout<<"Nubmer of times you selected above options: "<<endl;
cout<<"1) Ali "<<a<<" times."<<endl;
cout<<"2) Bravo "<<b<<" times."<<endl;
cout<<"3) Kumar "<<c<<" times."<<endl;
cout<<"4) Umair "<<d<<" times."<<endl;
}
No comments:
Post a Comment