Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int count(string word)
- {
- int upper = 0, lower = 0, number = 0, special = 0;
- for (int i = 0; i < word.length(); i++)
- {
- if (word[i] >= 65 && word[i] <= 90)
- upper++;
- else if (word[i] >= 97 && word[i] <= 122)
- lower++;
- else if (word[i]>= 48 && word[i]<= 57)
- number++;
- else
- special++;
- }
- cout << "Uppercase letters: " << upper << endl;
- cout << "Lowercase letters: " << lower << endl;
- cout << "Number: " << number << endl;
- cout << "Special characters: " << special << endl;
- }
- int main()
- {
- string word;
- cout<<"Enter your word: ";
- cin >>word;
- getline(cin, word);
- cout<<word.length()<<endl;
- count(word);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement