Advertisement
fahimkamal63

Count type of Characters

May 7th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cctype>
  4. using namespace std;
  5. int main(){
  6.     int t; cin >> t;
  7.     while(t--){
  8.         string s; cin >> s;
  9.         int upper = 0, lower = 0, numbers = 0, special = 0;
  10.         for(int i = 0; i < s.size(); i++){
  11.             if(isupper(s[i])) upper++;
  12.             else if(islower(s[i])) lower++;
  13.             else if(isdigit(s[i])) numbers++;
  14.             else special++;
  15.         }
  16.         cout << upper << endl;
  17.         cout << lower << endl;
  18.         cout << numbers << endl;
  19.         cout << special << endl;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement