Challenge #1

0 Harshad Lele · May 14, 2015
Hey ,

completed  #Challenge1

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

int main()
{
    char password[100];
    int i,a,b,c;

    printf("Enter your password : ");
    scanf( "%s" , &password);

    for (i= 0 ; i < strlen(password); i++ )
    {
        if  ( isupper(password) )
                a=1;
        else if ( isdigit(password) )
                b=1;
        else if ( password== '$' )
                c =1;
    }
        if (a == 1 && b == 1 && c == 1)
        printf("Your password is Good");
        else
        printf("your password sucks");

     return 0;
}

if this the optimized way of doing it? Can it get better? 

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Nishad Samant · May 16, 2015
This code is not going to work, the logic you are using needs to check each character of the password individually... and not the entire string together....use that hint...and rewrite the code again
  • 1
  • 2

C

107,077 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator