| 1 | 
 | 
 | 2 | 
 | 
 | 3 | #include <iostream>
 | 
 | 4 | #include <cctype>
 | 
 | 5 | 
 | 
 | 6 | using namespace std;
 | 
 | 7 | 
 | 
 | 8 | 
 | 
 | 9 | int main (){
 | 
 | 10 |     cout << "Enter password: ";
 | 
 | 11 |     string password;
 | 
 | 12 |     cin >> password;
 | 
 | 13 | 
 | 
 | 14 |     bool uppercase = false;
 | 
 | 15 |     bool lowercase = false;
 | 
 | 16 |     bool punct = false;
 | 
 | 17 |     bool digit = false;
 | 
 | 18 |     bool greaterThanEight = true;
 | 
 | 19 | 
 | 
 | 20 | 
 | 
 | 21 | 
 | 
 | 22 |     for (size_t i = 0; i < password.length(); i++)
 | 
 | 23 |     {
 | 
 | 24 |         int p = password[i];
 | 
 | 25 | 
 | 
 | 26 |         if(isupper(p))
 | 
 | 27 |         {
 | 
 | 28 |           uppercase = true; 
 | 
 | 29 |         }
 | 
 | 30 |         if (islower(p))
 | 
 | 31 |         {
 | 
 | 32 |            lowercase = true;
 | 
 | 33 |         }
 | 
 | 34 |         if (isdigit(p)
 | 
 | 35 |         ){
 | 
 | 36 |             digit = true;
 | 
 | 37 |         }
 | 
 | 38 |         if (ispunct(p))
 | 
 | 39 |         {
 | 
 | 40 |             punct = true;
 | 
 | 41 |         }
 | 
 | 42 |         
 | 
 | 43 |         
 | 
 | 44 |     }
 | 
 | 45 |     
 | 
 | 46 |     if(password.length() < 8){
 | 
 | 47 |         greaterThanEight = false;
 | 
 | 48 |         cout << "Password must be more than 8 characters" << endl;
 | 
 | 49 | 
 | 
 | 50 |     }
 | 
 | 51 |     if (!uppercase){
 | 
 | 52 |         cout << "Password must contain uppercase" << endl;
 | 
 | 53 |     }
 | 
 | 54 | 
 | 
 | 55 |       if (!lowercase){
 | 
 | 56 |         cout << "Password must contain lowercase" << endl;
 | 
 | 57 |     }
 | 
 | 58 | 
 | 
 | 59 |       if (!digit){
 | 
 | 60 |         cout << "Password must contain digit" << endl;
 | 
 | 61 |     }
 | 
 | 62 | 
 | 
 | 63 |       if (!punct){
 | 
 | 64 |         cout << "Password must contain a punctuation" << endl;
 | 
 | 65 |     }
 | 
 | 66 | 
 | 
 | 67 |     if (digit && punct && lowercase && uppercase && greaterThanEight){
 | 
 | 68 |         cout << "Password is super valid" << endl;
 | 
 | 69 |     }
 | 
 | 70 | 
 | 
 | 71 |     return 0;
 | 
 | 72 | }
 |