Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int count(string word)
  6. {
  7.  
  8. int upper = 0, lower = 0, number = 0, special = 0;
  9. for (int i = 0; i < word.length(); i++)
  10. {
  11. if (word[i] >= 65 && word[i] <= 90)
  12. upper++;
  13. else if (word[i] >= 97 && word[i] <= 122)
  14. lower++;
  15. else if (word[i]>= 48 && word[i]<= 57)
  16. number++;
  17. else
  18. special++;
  19. }
  20. cout << "Uppercase letters: " << upper << endl;
  21. cout << "Lowercase letters: " << lower << endl;
  22. cout << "Number: " << number << endl;
  23. cout << "Special characters: " << special << endl;
  24. }
  25.  
  26. int main()
  27. {
  28.  
  29. string word;
  30. cout<<"Enter your word: ";
  31. cin >>word;
  32. getline(cin, word);
  33. cout<<word.length()<<endl;
  34. count(word);
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement