Write A Program To Create Username And Password.

 


In this program user try to create username and password if any username and password condition in not satisfied then program give you some hint .


Code

#include<stdio.h> #include<string.h> int main(){ char str[25],pwd[20]; int a,i,h=0,m=0; printf("Enter the Username:"); scanf("%s",&str); if(strcmp(str,"JayDepani")==0 || strcmp(str,"DepaniJay")==0 || strcmp(str,"JayPatel")==0 || strcmp(str,"PatelJay")==0){ printf("\n This Username is Already there,please try to other Username."); return 0; } if(str[0]<'A' || str[0]>'Z'){ printf("\n First character of the Username should be Capital."); } for(i=0;str[i]!='\0';i++){ if(str[i]>='0' && str[i]<='9'){ m=1; break; } m=0; } if(m==1){ printf("\n Digit is not Allow in the Username."); } for(i=0;str[i]!='\0';i++){ if(str[i]=='~' || str[i]=='!' || str[i]=='@' || str[i]=='#' || str[i]=='$' || str[i]=='%' || str[i]=='^' || str[i]=='&' || str[i]=='*'){ m=1; break; } m=0; } if(m==1){ printf("\n Spacial Symbols are not Allow in Username."); return 0; } printf("\nEnter the Password:"); scanf("%s",&pwd); a=strlen(pwd); if(a<8 || a>15){ printf("\n Password length should be 8 to 15 characters."); } for(i=0;pwd[i]!='\0';i++){ if(pwd[i]>='0' && pwd[i]<='9'){ h=0; break; } h=1; } if(h==1){ printf("\n Minimum one digit is complasary to use in password like 1,2,3..."); } for(i=0;pwd[i]!='\0';i++){ if(pwd[i]=='~' || pwd[i]=='!' || pwd[i]=='@' || pwd[i]=='#' || pwd[i]=='$' || pwd[i]=='%' || pwd[i]=='^' || pwd[i]=='&' || pwd[i]=='*'){ h=0; break; } h=1; } if(h==1){ printf("\n Must be use one Spacial Symbols in Password like ~,!,@,#,$,%,^,&,*."); return 0; } for(i=0;pwd[i]!='\0';i++){ if(pwd[i]==' '){ h=1; break; } h=0; } if(h==1){ printf("\n Password should not contain any space."); return 0; } printf("\n Now Your Username is Created.\n Your Username is:%s",str); printf("\n Now your Password is Created.\n your Password is :%s",pwd); return 0; }


Output



you enter username if condition is not satisfy then its give you hint like this.



I give so many condition for username and password you can check my program.

i give you suggestion add and remove condition then check what new thing is add in your program.


Comments

Popular posts from this blog

Write A Program To Print Hello World Using Lex

Apply inline, internal and external style sheet for the student registration form.