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 Superman HC · May 28, 2015
12th line...

scanf (" %s ",&password); 

31st line..


if (lower> 0 && digit> 0 && upper> 0 && dollar> 0)

one more thing.. you have made a program in which the user has to enter exactly 10 characters in the password...
if you want to make it more user friendly.. try using while loop...
  • 1
  • 2

C

107,120 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator