Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- /*
- Challenge #1 Buckys Room
- Is password strong or weak by Goran
- */
- int main()
- {
- int upperCase = 0, number = 0, dolarSign = 0, loop;
- char password[20], temp; // 20 bytes for storing user password and char temp for storing one character for testing purpose.
- printf("Please enter your password: "); // asking user to enter his password.
- scanf(" %s", password); // gets input from user and stores it into char password.
- for(loop=0; loop<=20; loop++){ // loop that will start at 0, end at 20 and will increment by one.
- temp = password[loop]; // storing one character from user password at a time in char temp for testing.
- if(isupper(temp)){ // if character that we are testing is uppercase letter.
- upperCase++; // increment upperCase integer by one if statement above is true.
- }if(isdigit(temp)){ // if character that we are testing is number.
- number++; // increment number integer by one if statement above is true.
- }if(temp == '$'){ // if character that we are testing is dolar sign.
- dolarSign++; // increment dolarSign integer by one if statement above is true.
- }
- }if(upperCase >= 1 && number >= 1 && dolarSign >= 1){ // password need to have uppercase letter, number and dolar sign to be strong.
- printf("Your password is strong. \n \n"); // if statement above is true it will print out user that password he entered is strong.
- }else{
- printf("Your password is weak. \n \n"); // else if statement above is not true it will print out user that password he entered is weak.
- }
- system("pause"); // pausing program after executing.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement