Structured Programming
Structured Programming
Assignment
Course Code: CIS122
Course Title: Structured Programming
Assignment Title: Student’s Information Management
System (SIMS) of ‘Scholar English Medium School’
Fall 2019
Submitted To
Sajadul Chowdhury
Lecturer
Department of CIS
Daffodil International University
Submitted By
Md. Robiul Islam
ID: 181-16-254
Task 1
I. The flowchart for the login process of Student’s Information Management
System (SIMS) of ‘Scholar English Medium School given below here:
Login
User Name
No User Name or password does not
+ Password
= True match
Yes Attempt=Attempt+1
Main Menu
Yes
Attempt
=3
End
No
Exit
II. The flowchart for the process of selection a sub menu from the main menu
and also returning from a sub menu to the main menu or exit from the
software:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
Main Menu
Yes
Attempt=3
Enter Choice
No
Choice=True No Exit
Yes
Sub Menu
End
Sub Menu(add) to Main Menu:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
Enter Student Info
Yes
Yes Attempt=3
Enter
More=True
No
No Exit
Main Menu
End
Sub Menu (View) to Main Menu:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
View all Info
Yes
Attempt=3
Main Menu
No
End Exit
Sub Menu (Modify) to Main Menu:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
Enter Id to modify
Yes
Attempt=3
No
Id=True
Yes
No
Yes
More
try=True Exit
Modified
No
Main Menu
End
Sub Menu (delete) to Main Menu:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
Enter Id to Delete
Yes
Attempt=3
No
Id=True
No
Id Not Found Yes
Exit
Deleted
Main Menu
End
Sub Menu (Search) to Main Menu:
Start
User No
Info=True
Info does not match
Yes
Attempt=Attempt+1
Enter Id to Search
Yes
Attempt=3
No
Id=True
No
Id Not Found Yes
Exit
Searched Result
Main Menu
End
III. The pseudo code/ algorithm for the above problem:
Main menu()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
If((fp=fopen(txt,rb+))==NULL)
If((fp=fopen(txt,wb+))==NULL)
Return 0;
While(1)
Default (exit 0 );
Return 1;
Void add()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
While(another==y ||another ==y)
If (another!=y)
While (fread(&s,size,1,fp))==1)
System(pause);
Void view()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
While (fread(&s,size,1,fp))==1)
System(pause);
Void modify()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
While (another==y||another==y)
Enter id to modify;
Rewind;
While((fread(&s,size,1,fp))==1)
If(s.id==tempid)
Flag=1; break;
If(flag==1)
Modify info;
Fwrite(&s,sizeof(s),1,fp);
Else
Error;
Fflush(stdin);
Another=getchar():
Void search()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
While(another==y||another==y)
Enter id to search;
Rewind();
While(fread(&s,size,1fp))==1)
If(s.id==tempid)
Flag=1; break;
If(flag==1)
Show info;
Else
Error;
Return (fp);
File *del()
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
If((srtcmp(username)==0&&(strcmp(password)==0))
Login success;
Else
Login failed;
Exit;
If(ft=fopen(txt,wb+))==NULL)
Error;
System(pause);
Return fp;
Else
Enter id to delete;
Rewind();
While((fread(&s,size,1,fp))==1)
If(s.id=tempid)
Flag=1;
Deleted record;
Continue;
Fwrite(&s,size,1,ft);
Fclose();
Fclose();
Remove(student info);
If((fp=fopen(“txt,rb+))==NULL)
Error;
Return NULL;
If(flag==0)
System(pause);
Return fp;
Task 2
II.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
struct Stud
char name[100];
char address[50];
int id;
char phone[100];
char email[100];
char fathername[100];
};
III.
int main()
char username[15];
char password[12];
int i;
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
return 0;
}
IV.
FILE * fp;
Student s;
int option;
char another;
if((fp=fopen("studentInfo.txt","rb+"))==NULL)
if((fp=fopen("studentInfo.txt","wb+"))==NULL)
return 0;
while(1)
printf("\n\t");
printChar('-',110);
switch(option)
case 1:
add(fp);
break;
case 2:
view(fp);
break;
case 3:
modify(fp);
break;
case 4:
search(fp);
break;
case 5:
fp=del(fp);
break;
case 6:
return 1;
break;
default:
printf("\n\t\tYou Pressed wrong key");
printf("\n\t\tProgram terminated");
getch();
exit(0);
return 1;
while(n--)
putchar(ch);
}
V.
char username[15];
char password[12];
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
return 0;
}
char another='y';
Student s;
int i;
float cgpa;
fseek(fp,0,SEEK_END);
while(another=='y'||another=='Y')
fflush(stdin);
fgets(s.name,100,stdin);
s.name[strlen(s.name)-1]='\0';
fflush(stdin);
fgets(s.address,50,stdin);
s.address[strlen(s.address)-1]='\0';
scanf("%d",&s.id);
fflush(stdin);
fgets(s.phone,100,stdin);
s.phone[strlen(s.phone)-1]='\0';
printf("\n\n\t\tStudent's email: \t");
fflush(stdin);
fgets(s.email,100,stdin);
s.email[strlen(s.email)-1]='\0';
fflush(stdin);
fgets(s.fathername,100,stdin);
s.fathername[strlen(s.fathername)-1]='\0';
fwrite(&s,sizeof(s),1,fp);
fflush(stdin);
another=getchar();
if(another!='y')
Student s;
int i,siz=sizeof(s);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
printf("\n\t\tname : %s",s.name);
printf("\n\n\t\tAddress : %s",s.address);
printf("\n\n\t\tId : %d",s.id);
printf("\n\t\tphone : %s",s.phone);
printf("\n\t\temail : %s",s.email);
printf("\n\n\n\t");
printChar('*',110);
printf("\n\n\t");
system("pause");
char username[15];
char password[12];
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
{
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
return 0;
Student s;
int i,siz=sizeof(s);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
printf("\n\t\tNAME : %s",s.name);
printf("\n\n\t\tAddress : %s",s.address);
printf("\n\n\t\tId : %d",s.id);
printf("\n\t\tphone : %s",s.phone);
printf("\n\t\temail : %s",s.email);
printf("\n\n\n\t");
printChar('*',110);
printf("\n\n\t");
system("pause");
char username[15];
char password[12];
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
Student s;
int i,flag=0,tempRoll,siz=sizeof(s);
float cgpa;
char another='y';
while(another=='y'||another=='Y')
scanf("%d",&tempRoll);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
if(s.id==tempRoll)
flag=1;
break;
}
if(flag==1)
fseek(fp,-siz,SEEK_CUR);
printf("\n\n\t\tRECORD FOUND");
fflush(stdin);
fgets(s.name,100,stdin);
s.name[strlen(s.name)-1]='\0';
printf("\n\n\t\tAddress: \t");
fflush(stdin);
fgets(s.address,50,stdin);
s.address[strlen(s.address)-1]='\0';
scanf("%d",&s.id);
fflush(stdin);
fgets(s.phone,100,stdin);
s.phone[strlen(s.phone)-1]='\0';
fflush(stdin);
fgets(s.email,100,stdin);
s.email[strlen(s.email)-1]='\0';
printf("\n\n\t\tStudent's father's name: \t");
fflush(stdin);
fgets(s.fathername,100,stdin);
s.fathername[strlen(s.fathername)-1]='\0';
fwrite(&s,sizeof(s),1,fp);
else
fflush(stdin);
another=getchar();
char username[15];
char password[12];
printf("\n\n\n\n\n\n\n\n\t\t\t\t\tPlease Enter The Username: ");
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
{
printf("\n\t\t\t\t*****!!!!! Wrong Username or Password !!!!!*****");
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
return 0;
Student s;
int i,flag=0,tempRoll,siz=sizeof(s);
float cgpa;
char another='y';
while(another=='y'||another=='Y')
{
scanf("%d",&tempRoll);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
if(s.id==tempRoll)
flag=1;
break;
if(flag==1)
fseek(fp,-siz,SEEK_CUR);
printf("\n\n\t\tRECORD FOUND");
fflush(stdin);
fgets(s.name,100,stdin);
s.name[strlen(s.name)-1]='\0';
printf("\n\n\t\tAddress: \t");
fflush(stdin);
fgets(s.address,50,stdin);
s.address[strlen(s.address)-1]='\0';
scanf("%d",&s.id);
fflush(stdin);
fgets(s.phone,100,stdin);
s.phone[strlen(s.phone)-1]='\0';
fflush(stdin);
fgets(s.email,100,stdin);
s.email[strlen(s.email)-1]='\0';
fflush(stdin);
fgets(s.fathername,100,stdin);
s.fathername[strlen(s.fathername)-1]='\0';
fwrite(&s,sizeof(s),1,fp);
}
else
fflush(stdin);
another=getchar();
char username[15];
char password[12];
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
{
printf("\n\t\tWelcome to Student's Information Management System (SIMS) of 'Scholar English
Medium School'");
else
return 0;
int tempRoll,flag,siz,i;
Student s;
char another='y';
siz=sizeof(s);
while(another=='y'||another=='Y')
scanf("%d",&tempRoll);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
if(s.id==tempRoll)
{
flag=1;
break;
if(flag==1)
printf("\n\t\tNAME : %s",s.name);
printf("\n\n\t\tADDRESS: %s",s.address);
printf("\n\n\t\tId : %d",s.id);
printf("\n\t\tphone : %s",s.phone);
printf("\n\t\temail : %s",s.email);
else
printf("\n\n\t");
system("pause");
return(fp);
}
FILE * del(FILE * fp)
char username[15];
char password[12];
int i;
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
{
else
scanf("%s",&username);
scanf("%s",&password);
if((strcmp(username,"robiul")==0)&&(strcmp(password,"111")==0))
else
return 0;
}
Student s;
int flag=0,tempRoll,siz=sizeof(s);
FILE *ft;
if((ft=fopen("temp.txt","wb+"))==NULL)
system("pause");
return fp;
scanf("%d",&tempRoll);
rewind(fp);
while((fread(&s,siz,1,fp))==1)
if(s.id==tempRoll)
flag=1;
printf("\n\n\t\t%s\n\n\t\t%s\n\n\t\t
%d\n\t",s.name,s.address,s.id,s.phone,s.email,s.fathername);
continue;
}
fwrite(&s,siz,1,ft);
fclose(fp);
fclose(ft);
remove("studentInfo.txt");
rename("temp.txt","studentInfo.txt");
if((fp=fopen("studentInfo.txt","rb+"))==NULL)
printf("ERROR");
return NULL;
if(flag==0)
printChar('-',110);
printf("\n\t");
system("pause");
return fp;