HomeWork in C...... need in 10 hours

profileSamG
group_assignment_cprogram.txt

/****************************Group No.07 Assignment**************************** ***************************Group Members: 1.Danda, Praveen 2.Rachamalla, Sandeep 3.Ghaida Almugrin 4.Alghamdi, Hoosam G. *******************************************************************************/ #include<stdio.h> /**********************STUDENT functions*****************/ void enterStudentDetails(); void printAllstudentsDetails(); int findStudentByRoleNumber(int); void findStudentByName(); int searchGmail(char[]); /************************ BOOK *****************/ void addBook(); void printAllBooksList(); int findBookById(int); void findBookById1(); void findBookByISBN(); void findBookByName(); /********************** Enter Studente Details ******************************/ void enterStudentDetails() { int roll,ch,res; char name[50],email[50]; int flag=0,flag1=0; FILE *fp; clrscr(); fp = fopen("student.txt","a"); printf("\n ENTER ROLL NUMBER : "); scanf("%d",&roll); flag=findStudentByRoleNumber(roll); if(flag!=1) { printf("ENTER NAME :\n"); scanf("%s",&name); printf("ENTER EMAIL:\n"); scanf("%s",&email); flag1=searchGmail(email); if(flag1!=1) { fprintf(fp,"%d %s %s\n",roll,name,email); } else { printf("\n email already registered, take a new Email\n"); } } else { printf("This Student Number already registered .If u want add new student take another New RoleNumber :\n"); } fclose(fp) ; } /******************* Search gmail ************************/ int searchGmail(char semail[50]) { int i,ch,roll; char email[50],name[50]; FILE *fm; fm = fopen("student.txt","r"); i=0; while(! feof(fm)) { fscanf(fm,"%d%s%s\n",&roll,&name,&email); if(strcmp(email,semail)==0) { i=1; printf("\nROLLNO. NAME GMAIL\n "); printf(" %d %s %s",roll,name,email); break; } } fclose(fm); return i; } /********************Print All Students Details**************/ void printAllstudentsDetails() { int rollno[100],x[100],i; char name[100][50],email[100][50]; FILE *fp; clrscr(); fp = fopen("student.txt","r"); i=0; printf("ROLLNO NAME EMAIL\n"); while(!feof(fp)) { fscanf(fp,"%d %s %s\n",&rollno[i],&name[i],&email[i]); printf(" %d %s %s\n",rollno[i],name[i],email[i]); i=i+1; } fclose(fp); printf("\n\n\nPRESS ANY KEY"); getch(); } /************************* Print Student Details using RoleNumber ***************************/ int findStudentByRoleNumber(int roll1) { int i,ch,roll,mark,sroll; char name[50],email[50]; FILE *fm; fm = fopen("student.txt","r"); i=0; while(! feof(fm)) { fscanf(fm,"%d%s%s\n",&roll,&name,&email); if(roll1==roll) { printf("\nROLLNO. NAME GMAIL\n "); printf(" %d %s %s\n",roll,name,email); i=1; break; }//endif } if(i==0) { printf("\n%d",roll1); printf(" Rolenumber does not exit in the record\n"); } fclose(fm); return i; } /************************* To find Student information using student name***************************/ void findStudentByName() { int i=0,roll,ch,mark,roll1; char name[50],email[50],sname[50]; FILE *fm; ch=1; while(ch) { fm = fopen("student.txt","r"); printf(" \n ENTER STUDENT NAME "); scanf("%s",&sname); while(! feof(fm)) { fscanf(fm,"%d%s%s\n",&roll,&name,&email); if(strcmp(sname,name)==0) { i=1; printf("\nROLLNO. NAME GMAIL\n "); printf(" %d %s %s",roll,name,email); break; } } // printf("------i----->%d",i); if(i==0) { printf("\n%s",sname); printf(" name does not exit in the record"); } printf("\n\npress 1 to see Another Student info, otherwise Press 0 to return to main menu: \n"); scanf("%d",&ch); fclose(fm); } } /************** BOOKS FUNCTIONS *******************/ void addBook() { int i,ch,res,sbookid,bookid,quantity,bookISBN,booksIdPresentEnter[50]; char bookName[50],author[50]; FILE *fp; clrscr(); fp = fopen("book.txt","a"); ch =1; while(ch) { printf("Enter no of books:"); scanf("%d",&quantity); printf("Enter book isbn :"); scanf("%d",&bookISBN); printf("Enter BookNAME :"); scanf("%s",&bookName); printf("Enter Author :"); scanf("%s",&author); for(i=quantity;i>=1;i--) { fp = fopen("book.txt","a"); res=0; printf("\nEnter book Id : "); scanf("%d",&sbookid); res=findBookById(sbookid); if(res!=1) { fprintf(fp,"%d %s %s %d %d \n",sbookid,bookName,author,quantity,bookISBN); booksIdPresentEnter[i]=sbookid; fclose(fp); } else { printf("\nBookID what ever you enterd already registered ,Take a new BookID "); i++; } } printf("\n \n press 1 to continue,0 to stop : "); scanf("%d",&ch); } fclose(fp) ; } /* --------------- PRINT ALL BOOKS-------------------------*/ void printAllBooksList() { int bookId[50],quantity[50],bookISBN[50],i; char bookName[100][50],author[50][100],ch; FILE *fp; clrscr(); fp = fopen("book.txt","r"); i=0; printf("BookNumber BookNAME Author NoOfBooks ISBN\n"); while(! feof(fp)) { fscanf(fp,"%d%s%s%d%d\n",&bookId[i],&bookName[i],&author[i],&quantity[i],&bookISBN[i]); printf("%d %s %s %d %d\n",bookId[i],bookName[i],author[i],quantity[i],bookISBN[i]); i=i+1; } fclose(fp); printf("\n\n\nPRESS ANY KEY"); getch(); } /* ---------------------- find book by ID --------------------*/ void findBookById1() { int i,ch,bid,isbn,quantity,sbid; char bname[50],author[50]; FILE *fm; ch=1; while(ch) { fm = fopen("book.txt","r"); printf(" \n ENTER BOOK ID :"); scanf("%d",&sbid); i=0; while(! feof(fm)) { //printf("------- find book by ID while 1-----\n"); fscanf(fm,"%d%s%s%d%d\n",&bid,&bname,&author,&quantity,&isbn); if(sbid==bid) { printf("\n bookID BookName Author quantity ISBNnumber\n "); printf(" %d %s %s %d %d\n",bid,bname,author,quantity,isbn); break; } else i=i+1; } printf("\n\npress 1 to see another book info, 0 to return to main menu\n"); scanf("%d",&ch); fclose(fm); } } /*-------int findBookById(int sbid)------*/ int findBookById(int sbid) { int i=0,ch,bid,isbn,quantity; char bname[50],author[50]; FILE *fm; fm = fopen("book.txt","r"); while(! feof(fm)) { fscanf(fm,"%d%s%s%d%d\n",&bid,&bname,&author,&quantity,&isbn); if(sbid==bid) { printf("\n bookID BookName Author quantity ISBNnumber\n"); printf(" %d %s %s %d %d\n",bid,bname,author,quantity,isbn); i=1; break; } } fclose(fm); return i; } /*--------------------------- findBookByISBN-----------------*/ void findBookByISBN() { int i,ch,bid,isbn,quantity,sisbn; char bname[50],author[50]; FILE *fm; ch=1; while(ch) { fm = fopen("book.txt","r"); printf(" \n ENTER BOOK ISBN :"); scanf("%d",&sisbn); i=0; while(! feof(fm)) { fscanf(fm,"%d%s%s%d%d\n",&bid,&bname,&author,&quantity,&isbn); if(isbn==sisbn) { printf("\n bookID BookName Author quantity ISBNnumber\n "); printf(" %d %s %s %d %d\n",bid,bname,author,quantity,isbn); break; } else i=i+1; } printf("\n\npress 1 to see another book info, 0 to return to main menu :"); scanf("%d",&ch); fclose(fm); } } /*--------------------------- find Book By its name-----------------*/ void findBookByName() { int ch,bid,isbn,quantity; char bname[50],author[50],sbname[50]; FILE *fm; ch=1; while(ch) { fm = fopen("book.txt","r"); printf(" \n ENTER BOOK NAME :"); scanf("%s",&sbname); while(!feof(fm)) { fscanf(fm,"%d %s %s %d %s\n",&bid,&bname,&author,&quantity,&isbn); if(strcmp(sbname,bname) == 0) { printf("\n bookID BookName Author quantity ISBNnumber\n "); printf(" %d %s %s %d %d\n",bid,bname,author,quantity,isbn); break; } } printf("\n\npress 1 to see another Book info, 0 to return to main menu :"); scanf("%d",&ch); fclose(fm); } } /**************** FUNC. ENDS************************/ void main() { int i,rollno[100],x[100],n,j,roll,c,roll1,sroll,res,sbid; char ch,name[100][10],email; while(c!=10) { printf("GIVE CHOICE--\n"); printf(" 1 TO ENTER STUDENT INFORMATION\n"); printf(" 2 TO SEE ALL STUDENTS INFORMATION\n"); printf(" 3 TO PRINT STUDENT INFOORMATION USING ROLL NO\n"); printf(" 4 TO PRINT STUDENT INFO. USING HIS NAME\n"); printf(" 5 TO ENTER New Book INFO.\n"); printf(" 6 TO PRINT ALL BOOKS INFO.\n"); printf(" 7 TO Find BOOK INFO by BookById.\n"); printf(" 8 TO Find Book Info By ISBN number.\n"); printf(" 9 TO Find Book Info By its Name.\n"); printf(" 10 QUIT \n\n--"); scanf("%d",&c); clrscr(); switch(c) { case 1: enterStudentDetails(); break; case 2: printAllstudentsDetails(); break; case 3: do { res=0; printf("Enter Student Roll Number-----> "); scanf("%d",&roll1); res=findStudentByRoleNumber(roll1); printf("\nDo u want search again if yes PRESS 1 else PRESS 0 :"); scanf("%d",&i); }while(i!=0); if(res==0) { printf("\nThis RoleNumberis not yet registered"); } break; case 4: findStudentByName(); break; case 5: addBook(); break; case 6: printAllBooksList(); break; case 7: findBookById1(); break; case 8: findBookByISBN(); break; case 9: findBookByName(); break; case 10: exit(); break; default: break; } } }