Assignment.7
Assignment.7
While implementing, follow the given instructions (MAX 15 user can register).
a)User id should start with N OR n and next two numbers must be 20 and total of 7 length.(ex:n200774)
b) Password should consist of at least one lower case, one upper case,one number, one special character and
minimum length of 6 and
maximum length of 9.
e) Email ID have at least 3 character elements before @rguktn.ac.in. (ex: [email protected]) f) After all details
are valid save the
-> Generate the unique serial Id's starts from 101. (Use the static storage class)
3) After successful registration, provide all the entered details along with the serial ID. Then show the menu.
If R is entered,
a) Ask the user to enter serial ID and password. b) If user exist and valid, show login successful with user id
(Provide user
to logout option- when selected logout again show the menu) otherwise show the menu.
4) If D is selected :
a) Ask the user to enter serial ID and password. b)If user exist and valid, show to his/her as Account deleted.
Note: While implementing, try to use Binary search, string methods and functions.
CODE:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
main()
char i,id[8],p[11],pw[11],pwd[15][11],ph[20],email[21];
int
c=0,x=0,d=0,u=0,l=0,sp=0,m=0,pho=0,j,mail=0,sn[16],copy=0,si=0,sno=100,del[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
};
while(1)
scanf("%s",&i);
switch(i)
case 'R':
do
scanf("%s",&id);
if(strlen(id)==7&&(id[0]=='n'||id[0]=='N')&&id[1]=='2'&&id[2]=='0')
for(i=3;i<strlen(id);i++)
{
if(id[i]<='9'&&id[i]>='0')
c=c+1;
if(c<4)
while(c<4);
do{
scanf("%s",&p);
if(strlen(p)>=6&&strlen(p)<=9)
for(i=0;p[i]!='\0';i++)
if(isupper(p[i])!=0)
u=1;
else if(islower(p[i])!=0)
l=1;
else if(isdigit(p[i])!=0)
d=1;
else
sp=1;
if(d==0||u==0||l==0||sp==0)
{
printf("your entered password is not valid\nenter again: ");
while(d==0||u==0||l==0||sp==0);
do
scanf("%s",&pw);
if(strcmp(pw,p)!=0)
while(strcmp(pw,p)!=0);
do{
scanf("%s",&ph);
if(strlen(ph)==10&&(ph[0]=='7'||ph[0]=='8'||ph[0]=='9'))
pho=1;
if(pho==0)
while(pho==0);
printf("enter email: ");
do{
scanf("%s",&email);
char com[14]="@rguktn.ac.in";
strrev(com);
strrev(email);
if(strncmp(com,email,13)==0)
strrev(email);
if(strncmp(id,email,7)==0)
mail=1;
if(mail==0)
while(mail==0);
sno=++sno;
sn[sno%15]=sno;
strcpy(pwd[sno%15],pw);
puts(id);
puts(pw);
printf("your mobile is: ");
puts(ph);
puts(email);
break;
case 'L':
scanf("%d",&sno);
if(sn[sno%15]==sno)
if(del[sno%15]==1)
do{
scanf("%s",&p);
if(strcmp(p,pwd[sno%15])==0)
x=1;
else
while(x!=1);
int log;
printf("if you want to logout press 1 else press 2");
scanf("%d",&log);
if(log==1)
else
else
break;
case 'D':
scanf("%d",&sno);
if(sn[sno%15]==sno)
else
do
scanf("%s",&p);
if(strcmp(p,pwd[sno%15])==0)
else
while(x!=5);
del[sno%15]=0;
break;
case 'E':
exit(0);
break;
default:
break;