I took the challenge #1 but..............

0 Sai Ram · July 26, 2015
I have a problem i don't know how to check if a password contains a symbol like!@#$%,etc 

PLEASE HELP!!!!!!!!!!!!!!!!
#include 
#include
#include
#include
#include

int main()
{
  int password;

  printf("Press a password \t (the password should contain at least contain 1 upper case letter & 1 number \n ");
  scanf(" %d",&password);

  if(isdigit(password)){
    printf("The password contains a digit \n");
    
  }else if(isupper(password)){
  printf("The password contains a Upper case letter \n");
  }

  return 0;
}



Post a Reply

Replies

Oldest  Newest  Rating
0 Steven the awesome · July 27, 2015
To check if a input value contains a special character in C. You can easily just add another else if to your if statement.

#include 
#include
#include
#include
#include

int main()
{
int password;

printf("Press a password \t (the password should contain at least contain 1 upper case letter & 1 number \n ");
scanf(" %d",&password);

if(isdigit(password)){
printf("The password contains a digit \n");

}else if(isupper(password)){
printf("The password contains a Upper case letter \n");
}else if(password === '$') {
printf("The password contains a $ sign \n");
}

return 0;
}
0 Sai Ram · September 13, 2015
thx man i really wasnt online this whole time was studying for my exams:D
  • 1

C

107,237 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator