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 Harshad Lele · May 18, 2015
@ c student - thank you yes my code got changed due to page formatting :)
@ Nishad - Yes I have did the exact thing you said in the post, thanks :)
@ Reynaldo - declare int i outside the for loop. You can not declare new variable inside the for loop. Also use char array. as identifying of  '$' can not be done using int array. Hope this helps :)
  • 1
  • 2

C

107,322 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator