fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // Exercise 5.9
  6. int main()
  7. {
  8. char c;
  9. int aCount = 0;
  10. int eCount = 0;
  11. int iCount = 0;
  12. int oCount = 0;
  13. int uCount = 0;
  14. int blankCount = 0;
  15. int newLineCount = 0;
  16. int tabCount = 0;
  17. while (cin >> noskipws >> c)
  18. {
  19. if( c == 'a' || c == 'A')
  20. aCount++;
  21. else if( c == 'e' || c == 'E')
  22. eCount++;
  23. else if( c == 'i' || c == 'I')
  24. iCount++;
  25. else if( c == 'o' || c == 'O')
  26. oCount++;
  27. else if( c == 'u' || c == 'U')
  28. uCount++;
  29. else if(c == ' ')
  30. blankCount++;
  31. else if(c == '\t')
  32. tabCount++;
  33. else if(c == '\n')
  34. newLineCount++;
  35. }
  36. cout << "The number of a's: " << aCount << endl;
  37. cout << "The number of e's: " << eCount << endl;
  38. cout << "The number of i's: " << iCount << endl;
  39. cout << "The number of o's: " << oCount << endl;
  40. cout << "The number of u's: " << uCount << endl;
  41. cout << "The number of blanks: " << blankCount << endl;
  42. cout << "The number of tabs: " << tabCount << endl;
  43. cout << "The number of new lines: " << newLineCount << endl;
  44. return 0;
  45. }
Success #stdin #stdout 0s 2900KB
stdin
This is a test or something
New line
12345
Test 21
stdout
The number of a's: 1
The number of e's: 5
The number of i's: 4
The number of o's: 2
The number of u's: 0
The number of blanks: 7
The number of tabs: 0
The number of new lines: 3