Hey guys, I am posting the code below for Challenge No. 1 in C Programming Tutorials.
This code works but PLEASE tell me how can I further make this code more crisp.

Also, I have a question, what if the user enter the password and it exceeds 20 characters, then I want the user to again enter the password, How can i do that?

Please state the same people.

Thanks tuna and bacon lover BUCKY for these tutorials. It helps a lot indeed :D !!


/* Ask the user to enter the password.
If the password contains an Uppercase Letter, A Number
'and' A Dollar sign,
Print the message "Your password is good to go !!"
else Print the message "Your password sucks !"
*/


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main()
{
    char pswd[20];
    int i=0, length=0, upper=0, number=0, dollar=0;

    printf("Enter the password (upto 20 characters) \n");
    scanf(" %s", pswd);
    printf("The password entered is: %s \n", pswd);

    while(pswd!='\0')
    {
        length++;
        i++;
    }

    if(length<=20)
    {
      printf("Length of password is: %d \n", length);
    }

    if (length>20)
    {
      printf("Entered password exceeds 20 characters !! \n");
    }

    for(i=0; i<=length; i++)
    {
        if(isupper(pswd))
        {
            upper=1;
        }

        if(isdigit(pswd))
        {
            number=1;
        }

        if(pswd=='$')
        {
            dollar=1;
        }

    }

    if(upper==1 && number==1 && dollar==1)
    {
        printf("Your password is good to go ! \n");
    }
    else
    {
        printf("Your password sucks ! \n");
    }

    return 0;
}