challenge #1... try it out

0 Jordan pulice · February 1, 2015
    int y;

    char password[21];
    int hasupper,haslower,hasnum,haswtf;

    hasupper = haslower = hasnum = haswtf = 0;

   do
   {
     printf("Enter Password: ");
     gets(password);
   } while (strlen(password) <=8);

    for (y  = 0; y < strlen(password); y++)
    {
       // printf("\ncharacter %d is %c\n", y, password[y]);

       if ( isalpha (password[y]) )
       {

         if (isupper(password[y]))
         {
             hasupper++;
             //printf("%c is an upper case letter", password[y]);
         }
         else
         {
             haslower++;
             // printf("%c is a lower case letter",password[y]);
         }

        }
        else
        {
          if(isdigit(password[y]))
          {
              hasnum++;
          //  printf("%c is a number", password[y]);
          }
          else if (password[y] == '$')
          {
              haswtf++;
          //  printf("%c is a OMG WTF is that", password[y]);
          }
        }

    }

    if (hasupper && haslower &&  hasnum && haswtf)
    {
        printf("Not half bad, contains %d lower %d upper %d number %d $\n", haslower,hasupper,hasnum,haswtf);
    }
    else
    {
        printf("really dude?\n");
    }

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · February 1, 2015
read the following before you put your life in danger again!!! :unsure:
http://stackoverflow.com/questions/22419866/is-the-gets-string-function-in-c-considered-a-bad-practice
  • 1

C

107,120 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator