Challenge 1 Completed

0 Chandler Wise · October 29, 2014
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main()
    char password[200];
    int hasCapital = 0;
    int hasNumber = 0;
    int hasDollar = 0;
    int x;

    printf("Hello and welcome to the Password checking system!\n");
    printf("Enter your password to get started:");
    scanf(" %s", &password);

    for(x = 0; x <= sizeOf(password)-1; x++){
            hasCapital = 1;
        else if(isalnum(password[x])){
            hasNumber = 1;
        else if(password[x] == '$'){
            hasDollar = 1;

    if((hasCapital && hasNumber && hasDollar) == 1){
        printf("The password is good and you are accepted!");
        printf("That's not a very good password!");
    return 0;

And if you want the code with documentation/Comments:

Post a Reply


Oldest  Newest  Rating
0 Chandler Wise · October 29, 2014
It's possible, but in my testing it didn't happen. To be honest I originally set it at 20, but I increased it for longer passwords(it could probably be around 40 or so characters max instead), but again it doesn't seem to occur, at least in my testing(although I won't deny that it would be possible for it to be passed instead). Although tbh, I had never considered that occurring before. However this code is rather flawed in several areas, and can probably be done better in several ways...
0 Chandler Wise · October 29, 2014
Uh thanks, is everything fine now?

Edit:I made another change
-2 Chandler Wise · October 29, 2014
If it's shorter then it should be able to accurately scan and determine whether or not it's it meets the requirements.
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator