Answer on Question#39293 – Programming - C++
#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
#define TIMES 20
int main()
{
char var;
vector<int> variants(4);
for(int i = 0; i < TIMES; ++i)
{
cout << "What type of variable does take four bytes in memory?" << endl;
cout << "\tA: char" << endl;
cout << "\tB: double" << endl;
cout << "\tC: int" << endl;
cout << "\tD: long long int" << endl;
cin >> var;
switch(tolower(var))
{
case 'a':
++variants[0];
break;
case 'b':
++variants[1];
break;
case 'c':
++variants[2];
break;
case 'd':
++variants[3];
break;
default:
cout << "You've inputed wrong variant of answer. Try again." << endl;
--i;
}
}
cout << "\nVariant A was chosen " << variants[0] << " times." << endl;
cout << "\nVariant B was chosen " << variants[1] << " times." << endl;
cout << "\nVariant C was chosen " << variants[2] << " times." << endl;
cout << "\nVariant D was chosen " << variants[3] << " times.\n" << endl;
system("PAUSE");
return 0;
}