Advertisement
Guest User

My Code

a guest
Apr 15th, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. int main()
  6. {
  7.     char password[100];
  8.     int i, numberOfChars=0, temp, number, symbol, capitalLetter;
  9.  
  10.     printf("Type in your password\n (it must include a capital letter, a number and a symbol\n\n");
  11.     scanf("%s", password);
  12.     for(temp=0; password[temp] != '\0'; temp++)
  13.     {
  14.         numberOfChars++;
  15.     }
  16.     for(i=0; i<=numberOfChars; i++ )
  17.     {
  18.         if(isupper(password[i]))
  19.         {
  20.             capitalLetter=1;
  21.             break;
  22.         }
  23.         else
  24.         {
  25.             capitalLetter=0;
  26.         }
  27.  
  28.  
  29.     }
  30.     for(i=0; i<=numberOfChars; i++)
  31.     {
  32.         if(isdigit(password[i]))
  33.         {
  34.             number=1;
  35.             break;
  36.         }
  37.         else
  38.         {
  39.             number=0;
  40.  
  41.         }
  42.     }
  43.     for(i=0; i<=numberOfChars; i++)
  44.     {
  45.         if(isalpha(password[i]) || isdigit(password[i]))
  46.         {
  47.             symbol=0;
  48.         }
  49.         else
  50.         {
  51.             symbol=1;
  52.             break;
  53.         }
  54.     }
  55.  
  56.     (capitalLetter==0) ? printf("You need a capital letter\n") : "";
  57.     (number==0) ? printf("You need a number\n") : "";
  58.     (symbol==0) ? printf("You need a symbol\n") : "";
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement