Challenge #1

0 James Moore · October 9, 2014
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main()
{
        char pw[20], c=0, a=0, b=0;

        int try;

        printf("Please enter a password \n");
        scanf("%s", pw);
        for(try=0;try<5; try++)
        {
         if(isdigit(pw)){
            c++;
         }else if(isupper(pw)){
            a++
         }else if(isalpha(pw)){
            b++;
         }
        }if(c>=1 && a>=1 && b>=1){
            printf("Your password i good");
        }else{
            printf("sorry your password is no good ");
            }



return 0;
}


//* Theres somthing wrong with my isupper when i run aside from that it works

Post a Reply

Replies

Oldest  Newest  Rating
0 James Moore · November 13, 2014
thanks guys
0 hamad ahmad · October 26, 2014
@Ajinkya,

you should use pass to make it work. as for loop has to go through whole word letter by letter which stored in pass as array.
0 Franz Schmidt · October 14, 2014
You should mind using "i" as counter cause buckysroom has a bug in the codetag.
The array-element with i as counter is recognized as bb-code: italic
0 Ajinkya Mystical · October 14, 2014
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main (void)
{
    char pass [20];
    int i, x=0, y=0, z=0;

    printf("Enter your password and I will tell you is it good or not :\n");
    scanf(" %s",&pass);

    for(i=0; i<= 20; i++){
        if (isupper(pass))
            x++;

        else if(isdigit(pass))
            y++;

        else if(pass=='$')
            z++;

        else
            continue;
    }

    printf("\n\n %d %d %d\n",x,y,z);

    if (x>=1 && y>=1 && z>=1)
        printf("Your password is good and I think it will be safe!\n");
    else
        printf("NO!!! Your password is not good Try using Uppercase , Numbers and $ sign.\n");

    return 0;

}
  • 1

C

107,301 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator