#include <iostream>
#include <algorithm>
#include <vector>
#include <cctype>
int main(int argc, char* argv[]) {
//Creating a vector. It's also dynamic array.
std::vector<char> genders;
//Input section using loop.
for(int i=0; i<10; i++) {
//Point. If the user entered the wrong letter and something else, start from here.
wrong_input:
//Variable that store the gender letter.
char gender;
//Ask the user.
std::cout << "Enter gender of student " << i+1 << " <F/M>: "; std::cin >> gender;
//Check if something went wrong. Basic Exception handling.
if(tolower(gender) == 'f' || tolower(gender) == 'm') {
//Send data into vector.
genders.push_back(tolower(gender));
} else {
std::cout << "Something went wrong. Try again for student " << i+1 << std::endl;
goto wrong_input;
}
}
//Inform the user.
std::cout << "\\The number of female students are " << std::count(genders.begin(), genders.end(), 'f') << "\\The number of male students are " << std::count(genders.begin(), genders.end(), 'm') << std::endl;
return 0;
}