fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int isVowel(char c) {
  6. char vowels[] = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
  7. for (int i = 0; i < 10; ++i) {
  8. if (vowels[i] == c) {
  9. return 1;
  10. }
  11. }
  12. return 0;
  13. }
  14.  
  15. const int MAX_SIZE = 100;
  16.  
  17. int main() {
  18. char v[MAX_SIZE];
  19. cout << "Introduceti un sir de caractere: ";
  20. cin.getline(v, MAX_SIZE); // Citeste linia de text
  21. int countVowel = 0; // Resetare contor
  22. int n = strlen(v); // Lungimea sirului citit
  23.  
  24. for (int i = 0; i < n; ++i) {
  25. if (isVowel(v[i])) {
  26. ++countVowel; // Incrementare contor vocal
  27. }
  28. }
  29. cout << "Numarul de vocale: " << countVowel << endl; // Afiseaza numarul de vocale
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5284KB
stdin
ana are mere
stdout
Introduceti un sir de caractere: Numarul de vocale: 6