Challenge 1 ..... Completed :) How is it ?

0 S-pil c · January 31, 2015
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>


/*Main program */

void main()
{
/* Variables*/
char password[20];


printf("Note: This program asks for a password and test it for specific requirements.\nThe requirements are : \n1. Enter a password not less than 8 characters and not more than 12 characters.\n2. Must contain one or more capital letters.\n3. Must have at least one dollar sign.\n4. Must contain at least 1 number.\n\n");
here:
puts("\nEnter a password:");
scanf("%s",password);
/*Test 1*/
if(strlen(password) < 8)
{
printf("Sorry Too short, try again");
goto here;
}else if(strlen(password) > 12)
{
puts("Sorry Too long, try again");
goto here;
}
/* Variables 2*/
int i,testupper =0,testnumber=0,testlower =0, testsymbol = 0;

/* Test 2*/
for(i=0;i<strlen(password);i++)
{
if(isupper(password))
{
testupper++;
}else if(isdigit(password))
{
testnumber++;
}else if( islower(password))
{
testlower++;
}else {
testsymbol++;
}

}

/*Test 3*/
if ( testupper>=1 && testnumber>=1 && testlower>=1 && testsymbol>=1 )
{
printf("Good job");
}else{
puts("Sorry Too long, try again");
goto here;
}

}




Post a Reply

Replies

Oldest  Newest  Rating
0 c student · January 31, 2015
http://i.imgur.com/AzGnW5h.png??
0 S-pil c · February 1, 2015
Thanks for d suggection .
  • 1

C

106,994 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator