Challenge 1 completed :)

0 osh Ranw · February 3, 2015


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main()
{
    char password[100];
    int output1=0,output2=0,output3=0,output4=0;
    int x=0;


    printf("what is your password ? \n (please include at least one uppercse,$ sign and a number,min 3 characters) \n ");
    scanf("%s", password);



do{

        if(strlen(password)==x){

            break;
        }


        if(isalpha(password[x])){
                            if(isupper(password[x])){
                               output2++;

                               }else{
                                output1++;

                               }



        }else if(isdigit(password[x])){
                    output4++;

        }else if(password[x] == '$'){
                    output3++;

        }else{
                printf("please check your password \n it may have a wrong character! \n\n");
                break;


        }

        x++;

}while(x <=100);


   if(output4 >0 && output3>0 && output2>0 && output1 >= 0){
    printf("your password is good to go \n\n");
   }else{
        printf("your password is worthless! \n\n");
   }

    return 0;
}




Ok guyz,is this working Ok.?


even though i only watched bucky's video up to challenge 1 so far,i had to add strlen after asking from a friend
:):)

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · February 3, 2015
test your code and see for yourself.  if you have any more issues, don't hesitate to ask.
0 J show · February 3, 2015
Bucky probably covered this but what isalpha and isdigit and isupper?
  • 1

C

107,101 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator