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) )
        else if ( isdigit(password) )
        else if ( password== '$' )
                c =1;
        if (a == 1 && b == 1 && c == 1)
        printf("Your password is Good");
        printf("your password sucks");

     return 0;

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

Post a Reply


- page 1
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...
0 Kandy Naz · May 27, 2015
hey friends, can you please check this code and let me know what is wrong
# include <stdio.h>
# include <stdlib.h>
# include <ctype.h>
# include <string.h>
# include <math.h>

int main ()


int password[10];
int i;
int lower, upper, digit, dollar =0;
printf (" enter your password\n");
scanf (" %c ",password);

for(i =1 ; i <= 10; i++)

if (isalpha(password))
if( isupper (password))

else if (isdigit(password))
digit ++;

} // for loop

if (lower && digit && upper && dollar)
printf ( "your password is strong and proceed further");
printf (" Bad Password, check your rules again !!");

return 0;

0 Superman HC · May 24, 2015
Sorry for the previous incomplete code...
Here is the code again:


int main(){
int j=0;
char pass[10];
int upper=0, lower=0, digit=0, sc=0;

printf("Enter your password:\n");

while(j!=' '){
else if(isdigit(pass[j])){
     printf("Password must contain atleast one upper case, one lower case, one digit and a special character");
    printf("Good to go");
0 Akshay Pimpalkar · May 22, 2015
@harshad thumbs up for your code...

i have a problem...if i deliberately enter a password without a lower case letter , then it is not showing error(i.e"your message sucks")......however it has to show error.

According to my code, i have included check for lower case letter and message corresponding to it, but it is not displaying error in the output when there is an absence of lower case letter. rather it is showing that "your password is perfect", which should not happen.

Your code is also not showing the same...what do you think? what should we do?
0 Reynaldo Gunawan · May 19, 2015
@Harshad i will keep that in mind. Thanks for your reply
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 :)
0 Reynaldo Gunawan · May 18, 2015
Hi, I tried to do this challenge but I can't seem to get the code right and make the program work the way i want it. Can someone please take a look and maybe spot the mistakes that i made? That would be cool.
0 c student · May 17, 2015
Have you actually tried reading what I wrote before typing that?
0 Nishad Samant · May 17, 2015
The functions isupper() isdigit() etc are used to check the characters passed, here he is passing the entire will not work...he has to index each character of the string indicidually
0 c student · May 17, 2015
@Nishad Samant  If you haven't looked closely enough, he has actually placed in the index of his array.  You can tell because the text is italicized from where you'd expect it to be.  The page has read the index as part of its formatting.
  • 1
  • 2



One of the most popular languages of all time.

Bucky Roberts Administrator