Challenge 1 completed

+4 Горан Куга · October 13, 2014
Hi guys. I'm done with challenge 1 waiting for your suggestions on my code. I also provide same code but with comments http://pastebin.com/qYzvMmuZ.
#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;
printf("Please enter your password: ");
scanf(" %s", password);

for(loop=0; loop<=20; loop++){
temp = password[loop];
if(isupper(temp)){
upperCase++;
}if(isdigit(temp)){
number++;
}if(temp == '$'){
dolarSign++;
}

}if(upperCase >= 1 && number >= 1 && dolarSign >= 1){
printf("Your password is strong. \n \n");
}else{
printf("Your password is weak. \n \n");
}

system("pause");
return 0;
}

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
-3 Ajinkya Mystical · October 14, 2014
// Here is my version to the problem!!
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main (void)
{
    char pass [20];
    int i, x=0, y=0, z=0;

    printf("Enter your password and I will tell you is it good or not :\n");
    scanf(" %s",&pass);

    for(i=0; i<= 20; i++){
        if (isupper(pass))
            x++;

        else if(isdigit(pass))
            y++;

        else if(pass=='$')
            z++;

        else
            continue;
    }

    printf("\n\n %d %d %d\n",x,y,z);

    if (x>=1 && y>=1 && z>=1)
        printf("Your password is good and I think it will be safe!\n");
    else
        printf("NO!!! Your password is not good Try using Uppercase , Numbers and $ sign.\n");

    return 0;

}
  • 1
  • 2

C

107,220 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator