Challenge #1

0 Anushka Mehra · October 6, 2015
int main(){
    printf("Your password should be atleast 4 characters long \n ");
    char a[30];
    printf("Enter your password here: \n");
    scanf("%s",a);
    int c1,c2,c3,i;
    c1,c2,c3=0;

    if(sizeof(a)>3){
        for (i=0;i<sizeof(a);i++){
            if (isupper(a)){
                c1+=1;}
            else if(islower(a)){
                c2+=1;}
            else if(isdigit(a)){
                c3+=1;
            }}
        }
    if(c1>=1 && c2>=1 && c3>=1){
            printf("perfect password");
        }
    else{
        printf("invalid");
        }







       return 0;


}

Post a Reply

Replies

Oldest  Newest  Rating
0 siddharth pal · October 26, 2015
1. I've never read this sizeof() function. you can use strlen() for this function.
2. I dont think we can use isupper()  in array like you did.
isupper(a)


use 

isupper(a[])
0 Aquilas Mulamba · October 31, 2015
I try #Anushka Mehra code but it is not working...
0 c student · October 31, 2015
the sizeof operator determines the size of memory which is allocated for your variable.  your sizeof a will always be 30.
#include <assert.h>

int main(void) {
   char a[30];                  // 30 bytes
   assert (sizeof(a) == 30);    // true

   return 0;
}
0 Anushka Mehra · November 1, 2015
yes it is one of the functions in c++, so i thought it would work but it didnt , i didnt check properly before posting , so please use ignore it , iterate through the char to get the length 

*apologies*
  • 1

C

107,091 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator