0% found this document useful (0 votes)
4 views

Assignment.7

The document provides a C program for user registration, login, and deletion with specific validation rules for user ID, password, phone number, and email. It includes a menu for the user to choose between registration, login, deletion, and exit options, while ensuring that only a maximum of 15 users can register. The program utilizes string methods and functions, along with a static storage class for unique serial ID generation starting from 101.

Uploaded by

saiharshitha2005
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment.7

The document provides a C program for user registration, login, and deletion with specific validation rules for user ID, password, phone number, and email. It includes a menu for the user to choose between registration, login, deletion, and exit options, while ensuring that only a maximum of 15 users can register. The program utilizes string methods and functions, along with a static storage class for unique serial ID generation starting from 101.

Uploaded by

saiharshitha2005
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

Write a c program to implement registration of the user (user


id,email,password,repassword,phonenumber) and then allowed to login with

serial id and password. if requested to delete, delete the user.

While implementing, follow the given instructions (MAX 15 user can register).

1)Menu should be provided as registration(R),Login(L),Delete(D)and exit(E).

2)While registration means when user enters character R:

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.

c) Re password should be matched with the Password entered.

d) Phone number should start with 7 or 8 or 9 and a length of 10.

e) Email ID have at least 3 character elements before @rguktn.ac.in. (ex: [email protected]) f) After all details
are valid save the

password along with the generated Serial Id.

-> 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,

go for registration of another user.

If L is chosen means login:

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.

5) Follow the process until the user / Admin selects E.

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)

printf("\nenter R for regestration\nenter L for login\nenter D for delete\nenter E for exit");

printf("\nenter your choice ");

scanf("%s",&i);

switch(i)

case 'R':

printf("enter your user id: ");

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)

printf("your user id is not valid\nplease enter valid one: ");

while(c<4);

printf("enter a password: ");

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);

printf("conform your password: ");

do

scanf("%s",&pw);

if(strcmp(pw,p)!=0)

printf("password is not matching\nreenter again: ");

while(strcmp(pw,p)!=0);

printf("enter your mobile number: ");

do{

scanf("%s",&ph);

if(strlen(ph)==10&&(ph[0]=='7'||ph[0]=='8'||ph[0]=='9'))

pho=1;

if(pho==0)

printf("phone number is not valid\nenter valid phone number: ");

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)

printf("entered mail is wrong\nreenter your mail again: ");

while(mail==0);

printf("all entered data is valid\n");

sno=++sno;

printf("your serial number is: %d\n",sno);

sn[sno%15]=sno;

strcpy(pwd[sno%15],pw);

printf("your user id is: ");

puts(id);

printf("your password is: ");

puts(pw);
printf("your mobile is: ");

puts(ph);

printf("your email is: ");

puts(email);

break;

case 'L':

printf("enter serial number: ");

scanf("%d",&sno);

if(sn[sno%15]==sno)

if(del[sno%15]==1)

printf("enter your password: ");

do{

scanf("%s",&p);

if(strcmp(p,pwd[sno%15])==0)

printf("your login is succesful\n");

x=1;

else

printf("your entered password is wrong enter again ");

while(x!=1);

int log;
printf("if you want to logout press 1 else press 2");

scanf("%d",&log);

if(log==1)

printf("you have logged out");

else

printf("you havent yet registered please register first.");

else

printf("you havent yet registered please register first.");

break;

case 'D':

printf("enter serial number: ");

scanf("%d",&sno);

if(sn[sno%15]==sno)

printf("enter your password: ");

else

printf("yo are not registered");

do

scanf("%s",&p);

if(strcmp(p,pwd[sno%15])==0)

printf("your account is deleted: ");


x=5;

else

printf("your password is wrong please reenter again ");

while(x!=5);

del[sno%15]=0;

break;

case 'E':

exit(0);

break;

default:

printf("enter valid option");

break;

You might also like