Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include<stdlib.h>
- typedef struct src
- {
- char name[30];
- char id[15];
- float marksds;
- float marksec;
- float marksdm;
- float marksde;
- float gpds;
- float gpec;
- float gpdm;
- float gpde;
- char gradeds[3];
- char gradeec[3];
- char gradedm[3];
- char gradede[3];
- char commentds[20];
- char commentec[20];
- char commentdm[20];
- char commentde[20];
- float gp;
- char comment[30];
- struct src *ptr;
- } src;
- src *head=NULL,*temp,*x;
- float final(char c[],float a,float b,float i,float j)
- {
- float e=(a+b+i+j)/4;
- if(e==4.00)
- {
- strcpy(c,"Outstanding");
- }
- else if(e<4.00&&e>=3.75)
- {
- strcpy(c,"Excellent");
- }
- else if(e<3.75&&e>=3.50)
- {
- strcpy(c,"Very Good");
- }
- else if(e<3.50&&e>=3.25)
- {
- strcpy(c,"Good");
- }
- else if(e<3.25&&e>=3.00)
- {
- strcpy(c,"Satisfactory");
- }
- else if(e<3.00&&e>=2.75)
- {
- strcpy(c,"Above Average");
- }
- else if(e<2.75&&e>=2.50)
- {
- strcpy(c,"Average");
- }
- else if(e<2.50&&e>=2.25)
- {
- strcpy(c,"Bellow Average");
- }
- else if(e<2.25&&e>=2.00)
- {
- strcpy(c,"Pass");
- }
- else if(e<2.00&&e>=0.00)
- {
- strcpy(c,"Fail");
- }
- return e;
- }
- float grade(char c[],char d[],float a)
- {
- if(a>=80&&a<=100)
- {
- strcpy(c,"A+");
- strcpy(d,"Outstanding");
- return 4;
- }
- else if(a>=75.00&&a<=79.00)
- {
- strcpy(c,"A");
- strcpy(d,"Excellent");
- return 3.75;
- }
- else if(a>=70&&a<=74)
- {
- strcpy(c,"A-");
- strcpy(d,"Very Good");
- return 3.50;
- }
- else if(a>=65&&a<=69)
- {
- strcpy(c,"B+");
- strcpy(d,"Good");
- return 3.25;
- }
- else if(a>=60&&a<=64)
- {
- strcpy(c,"B");
- strcpy(d,"Satisfactory");
- return 3;
- }
- else if(a>=55&&a<=59)
- {
- strcpy(c,"B-");
- strcpy(d,"Avobe Average");
- return 2.75;
- }
- else if(a>=50&&a<=54)
- {
- strcpy(c,"C+");
- strcpy(d,"Average");
- return 2.50;
- }
- else if(a>=45&&a<=49)
- {
- strcpy(c,"C");
- strcpy(d,"Bellow Average");
- return 2.25;
- }
- else if(a>=40&&a<=44)
- {
- strcpy(c,"D");
- strcpy(d,"Pass");
- return 2;
- }
- else if(a>=0&&a<=39)
- {
- strcpy(c,"F");
- strcpy(d,"Fail");
- return 0;
- }
- }
- void insertion()
- {
- while(1)
- {
- x=(src*)malloc(sizeof(src));
- printf("\nEnter The Name: ");
- scanf(" %[^\n]s",&x->name);
- printf("Enter The Id : ");
- scanf(" %[^\n]s",&x->id);
- printf("\nEnter The Marks:\n");
- printf("----------------\n");
- printf("Marks For Data Structure : ");
- scanf("%f",&x->marksds);
- x->gpds=grade(x->gradeds,x->commentds,x->marksds);
- printf("Marks For Electrical Circuit : ");
- scanf("%f",&x->marksec);
- x->gpec=grade(x->gradeec,x->commentec,x->marksec);
- printf("Marks For Discrete Math : ");
- scanf("%f",&x->marksdm);
- x->gpdm=grade(x->gradedm,x->commentdm,x->marksdm);
- printf("Marks For Differential Equation: ");
- scanf("%f",&x->marksde);
- x->gpde=grade(x->gradede,x->commentde,x->marksde);
- x->gp=final(x->comment,x->gpds,x->gpec,x->gpdm,x->gpde);
- x->ptr=NULL;
- printf("-------------------------------------------------------------------------------");
- if(head==NULL)
- {
- head=x;
- }
- else
- {
- temp=head;
- while(temp->ptr!=NULL)
- {
- temp=temp->ptr;
- }
- temp->ptr=x;
- }
- printf("\n\t\t\tContinue Getting Information(Y/N)");
- printf("\n-------------------------------------------------------------------------------");
- char ch=getch();
- if(ch=='N'||ch=='n')
- {
- break;
- }
- }
- main2();
- }
- void printall()
- {
- int c;
- printf("\n ----------");
- printf("\n ALL RECORD:");
- printf("\n ----------");
- temp=head;
- if(temp==NULL)
- {
- printf("\n\t\t\tRecord Empty.\n");
- }
- while(temp!=NULL)
- {
- printf("\n Student Name: %s\n Student Id : %s\n\n",temp->name,temp->id);
- printf(" Course Title\t\t Grade\t Grade Point\t Comment\n");
- printf(" ------------\t\t -----\t -----------\t -------\n");
- if(temp->gradeds[1]=='+'||temp->gradeds[1]=='-')
- {
- printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
- }
- else
- {
- printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
- }
- if(temp->gradeec[1]=='+'||temp->gradeec[1]=='-')
- {
- printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
- }
- else
- {
- printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
- }
- if(temp->gradedm[1]=='+'||temp->gradedm[1]=='-')
- {
- printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
- }
- else
- {
- printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
- }
- if(temp->gradede[1]=='+'||temp->gradede[1]=='-')
- {
- printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
- }
- else
- {
- printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
- }
- printf("\n\t\t\t SGPA= %.2f\t\t %s\n",temp->gp,temp->comment);
- temp=temp->ptr;
- printf("-------------------------------------------------------------------------------\n");
- }
- printf("\n-------------------------------------------------------------------------------\n");
- printf("\t\t\tMAIN MENU OR TERMINATE(M/T)");
- printf("\n-------------------------------------------------------------------------------\n");
- char ch=getch();
- if(ch=='M'||ch=='m')
- {
- main2();
- }
- }
- void search()
- {
- int b=0;
- char d[30];
- printf("\nEnter The Id: ");
- scanf(" %[^\n]s",&d);
- printf("-------------------------------------------------------------------------------\n");
- temp=head;
- while(temp!=NULL)
- {
- if(strcmp(temp->id,d)==0)
- {
- b=1;
- break;
- }
- else
- {
- temp=temp->ptr;
- }
- }
- if(b==0)
- {
- printf("Record Not Found\n");
- }
- else
- {
- printf("\n Student Name: %s\n Student Id : %s\n\n",temp->name,temp->id);
- printf(" Course Title\t\t Grade\t Grade Point\t Comment\n");
- printf(" ------------\t\t -----\t -----------\t -------\n");
- if(temp->gradeds[1]=='+'||temp->gradeds[1]=='-')
- {
- printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
- }
- else
- {
- printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
- }
- if(temp->gradeec[1]=='+'||temp->gradeec[1]=='-')
- {
- printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
- }
- else
- {
- printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
- }
- if(temp->gradedm[1]=='+'||temp->gradedm[1]=='-')
- {
- printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
- }
- else
- {
- printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
- }
- if(temp->gradede[1]=='+'||temp->gradede[1]=='-')
- {
- printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
- }
- else
- {
- printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
- }
- printf("\n\t\t\t SGPA= %.2f\t\t %s\n",temp->gp,temp->comment);
- printf("-------------------------------------------------------------------------------\n");
- }
- printf("-------------------------------------------------------------------------------\n");
- printf("\t\t\tMAIN MENU OR CONTINUE(M/C)");
- char ch=getch();
- if(ch=='C'||ch=='c')
- {
- printf("\n-------------------------------------------------------------------------------\n");
- search();
- }
- else
- {
- main2();
- }
- }
- int help(char d[])
- {
- int b=0;
- temp=head;
- while(temp!=NULL)
- {
- if(strcmp(temp->id,d)==0)
- {
- b=1;
- break;
- }
- else
- {
- temp=temp->ptr;
- }
- }
- return b;
- }
- void delete()
- {
- char d[30];
- int b=0,c;
- src *temp1;
- printf("\nEnter The Id: ");
- scanf(" %[^\n]s",&d);
- printf("----------------\n");
- c=help(d);
- if(c==0)
- {
- printf(" Unsuccesful\n");
- goto bue;
- }
- temp=head;
- if(strcmp(head->id,d)==0)
- {
- head=head->ptr;
- free(temp);
- b=1;
- }
- temp=head;
- while(temp!=NULL)
- {
- if(strcmp(temp->id,d)==0)
- {
- b=1;
- temp1->ptr=temp->ptr;
- free(temp);
- break;
- }
- else
- {
- temp1=temp;
- temp=temp->ptr;
- }
- }
- if(b==0)
- {
- printf(" Unsuccesful\n");
- }
- else
- {
- printf(" Succesful\n");
- }
- bue:
- printf("-------------------------------------------------------------------------------\n");
- printf("\t\t\tMAIN MENU OR CONTINUE(M/C)");
- char ch=getch();
- if(ch=='c'||ch=='C')
- {
- printf("\n-------------------------------------------------------------------------------\n");
- delete();
- }
- else
- {
- main2();
- }
- }
- void main2()
- {
- int a;
- printf("\n-------------------------------------------------------------------------------");
- printf("\n\t 1. For Adding Student Information.\n");
- printf("\t 2. For Deleting Student Information.\n");
- printf("\t 3. For Displaying All Student Information.\n");
- printf("\t 4. For Displaying Specific Student Information.\n");
- printf("\t 5. For Closing The Program");
- printf("\n-------------------------------------------------------------------------------");
- printf("\nChoose The Operation: ");
- scanf(" %d",&a);
- printf("-------------------------------------------------------------------------------");
- if(a==1)
- {
- insertion();
- }
- else if(a==2)
- {
- delete();
- }
- else if(a==3)
- {
- printall();
- }
- else if(a==4)
- {
- search();
- }
- else if(a==5)
- {
- return 0;
- }
- }
- int main()
- {
- system("COLOR 0B");
- printf("\t\t\t---------------------\n");
- printf("\t\t\t STUDENT REPORT CARD\n");
- printf("\t\t\t---------------------\n");
- main2();
- return 0;
- }
Add Comment
Please, Sign In to add comment