My Challenge #1 Answer

+3 Korl Kevs · February 2, 2015

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

/*This program will detect if your password has a lowercase,uppercase,symbol and number*/

int main()
{
    char password[20];
    int valid=0,num=0,upper=0,lower=0,symbol=0,i;

do{
    printf("Enter Password:\n");
    scanf("%s",password);
    num=0,upper=0,lower=0,symbol=0;

    for(i=0;i<strlen(password);i++){
        if(isdigit(password)){
            num++;
        }
        else if(isalpha(password)){
            if(isupper(password)){
                upper++;
            }
            else{
                lower++;
            }
        }
        else{
            symbol++;
        }
    }
    if(num>0&&upper>0&&symbol>0&&lower>0){
        valid++;
        printf("Good Password\n");
    }
    else{
        printf("Invalid Password\n");
    }
}
    while(valid==0);

    return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 osh Ranw · February 2, 2015
not working for me!!
0 Korl Kevs · February 2, 2015
yes and i think there is nothing wrong with it.
  • 1

C

107,005 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator