Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<stdbool.h>
- char t_name[50];
- char t_mail[50];
- char t_pass[50];
- char t_id[50];
- char st_name[50];
- char st_mail[50];
- char st_pass[50];
- char st_id[50];
- int result[100] = {0};
- int st;
- struct node
- {
- char name[50];
- char code[20];
- struct node *next;
- }*head = NULL;
- void total_courses()
- {
- struct node *new_node, *current;
- new_node = (struct node*)malloc(sizeof(struct node));
- new_node->next = NULL;
- strcpy(new_node->name, "Algorithm");
- strcpy(new_node->code, "CSE214");
- head = new_node;
- current = new_node;
- struct node *new_node1 = (struct node*)malloc(sizeof(struct node));
- new_node1->next = NULL;
- strcpy(new_node1->name, "Data Communication");
- strcpy(new_node1->code, "CSE212");
- current->next = new_node1;
- current = new_node1;
- }
- void t_course()
- {
- struct node *current = head;
- printf("\nCourseList: \n\n");
- while(current != NULL)
- {
- printf("Course Name: %s\n", current->name);
- printf("Course Code: %s\n\n", current->code);
- current = current->next;
- }
- printf("\n\n");
- }
- void t_logIn()
- {
- char m[50], p[50];
- printf("\n\n**** Log-In ****\n\n");
- printf("Enter mail: ");
- scanf(" %[^\n]", m);
- printf("\nEnter password: ");
- scanf(" %[^\n]", p);
- if( (strcmp(m, t_mail) != 0) && (strcmp(p, t_pass) != 0) )
- {
- printf("\nError Data\n");
- t_logIn();
- }
- else
- {
- printf("\n\t**** Log-In Successful ****\n\n");
- }
- }
- void t_signUp()
- {
- printf("\nEnter name: ");
- scanf(" %[^\n]", t_name);
- printf("\nEnter mail: ");
- scanf(" %[^\n]", t_mail);
- printf("\nEnter id: ");
- scanf(" %[^\n]", t_id);
- printf("\nEnter pass: ");
- scanf(" %[^\n]", t_pass);
- printf("\n\t\t**** Sign-Up Successful ****\n");
- }
- void s_logIn()
- {
- char m[50], p[50];
- printf("\n\n**** Log-In ****\n\n");
- printf("Enter mail: ");
- scanf(" %[^\n]", m);
- printf("\nEnter password: ");
- scanf(" %[^\n]", p);
- if( (strcmp(m, st_mail) != 0) && (strcmp(p, st_pass) != 0) )
- {
- printf("\nError Data\n");
- s_logIn();
- }
- else
- {
- printf("\n\t**** Log-In Successful ****\n\n");
- }
- }
- void s_signUp()
- {
- printf("\nEnter name: ");
- scanf(" %[^\n]", st_name);
- printf("\nEnter mail: ");
- scanf(" %[^\n]", st_mail);
- printf("\nEnter id: ");
- scanf(" %[^\n]", st_id);
- printf("\nEnter pass: ");
- scanf(" %[^\n]", st_pass);
- printf("\n\t\t**** Sign-Up Successful ****\n");
- }
- void Student()
- {
- int n;
- printf("\nNew to this site(1/0): ");
- scanf("%d", &n);
- if(n == 1)
- {
- s_signUp();
- s_logIn();
- }
- else
- {
- s_logIn();
- }
- }
- void Teacher()
- {
- int n;
- printf("\nNew to this site(1/0): ");
- scanf("%d", &n);
- if(n == 1)
- {
- t_signUp();
- t_logIn();
- }
- else
- {
- t_logIn();
- }
- }
- void t_profile()
- {
- printf("\n\t*** Profile ***\n\n");
- printf("\tName: %s\n", t_name);
- printf("\tEmail: %s\n", t_mail);
- printf("\tId : %s\n", t_id);
- printf("\n\n");
- }
- void st_profile()
- {
- printf("\n*** Profile ***\n\n");
- printf("Name: %s\n", st_name);
- printf("Email: %s\n", st_mail);
- printf("Id : %s\n", st_id);
- printf("\n\n");
- }
- void swap(int* a, int* b)
- {
- int t = *a;
- *a = *b;
- *b = t;
- }
- int partition (int ara[], int low, int high)
- {
- int pivot = ara[high];
- int i = (low - 1);
- for (int j = low; j <= high- 1; j++)
- {
- if (ara[j] > pivot)
- {
- i++;
- swap(&ara[i], &ara[j]);
- }
- }
- swap(&ara[i + 1], &ara[high]);
- return (i + 1);
- }
- void quickSort(int ara[], int low, int high)
- {
- if (low < high)
- {
- int pi = partition(ara, low, high);
- quickSort(ara, low, pi - 1);
- quickSort(ara, pi + 1, high);
- }
- }
- void s_result()
- {
- printf("\nResult : \n");
- for(int i=0; i<st; i++)
- {
- printf("Roll %d: %d\n", i+1, result[i]);
- }
- printf("\n\n");
- }
- int main()
- {
- char ch, c;
- int n, a = 0, b, d;
- printf("\n\n\t\t\t****** Welcome to our College management system ******\n\n");
- printf("\n\tChoose category: \n\n");
- printf("\t1. Teacher\n");
- printf("\t2. Student\n\n");
- scanf("%d", &n);
- if(n == 1)
- {
- Teacher();
- a = 1;
- }
- else
- {
- Student();
- }
- while(1)
- {
- if(a == 1)
- {
- printf("\n\t***** Welcome to Teacher Portal *****\n\n");
- printf("\tChose an option:\n");
- printf("\t1.Profile\n\t2.Course\n\t3.Add result\n\t4.Show Student's result\n\t5.Exit\n");
- scanf("%d", &b);
- if(b == 1)
- {
- t_profile();
- }
- else if(b == 2)
- {
- total_courses();
- t_course();
- }
- else if(b == 3)
- {
- int i;
- printf("\nEnter the number of student in class: ");
- scanf("%d", &st);
- printf("\nAdd result: \n");
- for(i=0; i<st; i++)
- {
- printf("Roll %d: ", i+1);
- scanf("%d", &result[i]);
- }
- quickSort(result, 0, st-1);
- FILE *fp;
- fp = fopen("result.txt", "w");
- for(i=0; i<st; i++)
- {
- fprintf(fp, "Roll %d: %d\n",i+1, result[i]);
- }
- fclose(fp);
- }
- else if(b == 4)
- {
- s_result();
- printf("\n");
- }
- else if(b == 5)
- {
- break;
- }
- }
- else
- {
- printf("\n\t***** Welcome to Student Portal *****\n\n");
- printf("\tChose an option:\n");
- printf("\t1.Profile\n\t2.Course\n\t3.See result\n\t4.Exit\n");
- scanf("%d", &b);
- if(b == 1)
- {
- st_profile();
- }
- else if(b == 2)
- {
- total_courses();
- t_course();
- }
- else if(b == 3)
- {
- FILE *fp;
- fp = fopen("result.txt", "r");
- if(fp == NULL)
- {
- printf("\n\nResult has not published Yet\n\n");
- }
- else
- {
- int a;
- while(a != EOF)
- {
- a = fgetc(fp);
- putchar((char)a);
- }
- printf("\n\n");
- }
- }
- else if(b == 4)
- {
- break;
- }
- }
- }
- printf("\n\n\t\t********* Thank You :-) *********\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement