Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- int main()
- {
- char password[100];
- int i, numberOfChars=0, temp, number, symbol, capitalLetter;
- printf("Type in your password\n (it must include a capital letter, a number and a symbol\n\n");
- scanf("%s", password);
- for(temp=0; password[temp] != '\0'; temp++)
- {
- numberOfChars++;
- }
- for(i=0; i<=numberOfChars; i++ )
- {
- if(isupper(password[i]))
- {
- capitalLetter=1;
- break;
- }
- else
- {
- capitalLetter=0;
- }
- }
- for(i=0; i<=numberOfChars; i++)
- {
- if(isdigit(password[i]))
- {
- number=1;
- break;
- }
- else
- {
- number=0;
- }
- }
- for(i=0; i<=numberOfChars; i++)
- {
- if(isalpha(password[i]) || isdigit(password[i]))
- {
- symbol=0;
- }
- else
- {
- symbol=1;
- break;
- }
- }
- (capitalLetter==0) ? printf("You need a capital letter\n") : "";
- (number==0) ? printf("You need a number\n") : "";
- (symbol==0) ? printf("You need a symbol\n") : "";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement