#include using std::cout, std::endl; void count_letters(char str[], int& n_letters, int& n_digits, int& n_other) { while (*str) { if (*str >= 'a' && *str <= 'z' || *str >= 'A' && *str <= 'Z') { n_letters += 1; } else if (*str >= '0' && *str <= '9') { n_digits += 1; } else { n_other += 1; } str += 1; } } int main() { int n_letters = 0, n_digits = 0, n_other = 0; char s[] = "1n!2y#3a$"; count_letters(s, n_letters, n_digits, n_other); cout << "letters: " << n_letters << endl << "digits: " << n_digits << endl << "n_other: " << n_other << endl; }