#include <stdio.
h>
#include <string.h>
#include <stdlib.h>
#define MAX_USERS 100
#define MAX_COLLEGES 100
typedef struct {
char username[30];
char password[30];
char name[50];
int isAdmin;
} User;
typedef struct {
char name[50];
float cutoff;
} College;
User users[MAX_USERS];
College colleges[MAX_COLLEGES];
int totalUsers = 0;
int totalColleges = 0;
char currentUser[30];
int isCurrentAdmin = 0;
void loadData();
void saveData();
void welcomeScreen();
void registerUser(int asAdmin);
int loginUser();
void studentDashboard();
void adminDashboard();
void addCollege();
void editCollege();
void deleteCollege();
void viewAllColleges();
void predictAdmission();
int main() {
loadData();
welcomeScreen();
return 0;
void loadData() {
FILE *fp = fopen("[Link]", "rb");
if (fp != NULL) {
fread(&totalUsers, sizeof(int), 1, fp);
fread(users, sizeof(User), totalUsers, fp);
fclose(fp);
fp = fopen("[Link]", "rb");
if (fp == NULL) {
strcpy(colleges[0].name, "IIT Bombay"); colleges[0].cutoff = 99.8;
strcpy(colleges[1].name, "IIT Delhi"); colleges[1].cutoff = 99.7;
strcpy(colleges[2].name, "NIT Trichy"); colleges[2].cutoff = 98.5;
strcpy(colleges[3].name, "BITS Pilani"); colleges[3].cutoff = 97.0;
strcpy(colleges[4].name, "VIT Vellore"); colleges[4].cutoff = 95.0;
totalColleges = 5;
} else {
fread(&totalColleges, sizeof(int), 1, fp);
fread(colleges, sizeof(College), totalColleges, fp);
fclose(fp);
void saveData() {
FILE *fp = fopen("[Link]", "wb");
if (fp != NULL) {
fwrite(&totalUsers, sizeof(int), 1, fp);
fwrite(users, sizeof(User), totalUsers, fp);
fclose(fp);
fp = fopen("[Link]", "wb");
if (fp != NULL) {
fwrite(&totalColleges, sizeof(int), 1, fp);
fwrite(colleges, sizeof(College), totalColleges, fp);
fclose(fp);
void welcomeScreen() {
int choice;
while (1) {
system("cls");
printf("\n1. Admin Register\n");
printf("2. Admin Login\n");
printf("3. Student Register\n");
printf("4. Student Login\n");
printf("5. Exit\n");
printf("Choose: ");
scanf("%d", &choice);
if (choice == 1) registerUser(1);
else if (choice == 2 || choice == 4) loginUser();
else if (choice == 3) registerUser(0);
else if (choice == 5) exit(0);
else printf("Invalid\n");
printf("\nPress Enter...");
getchar(); getchar();
void registerUser(int asAdmin) {
if (totalUsers >= MAX_USERS) {
printf("Limit reached\n");
return;
printf("\nEnter Name: ");
getchar();
fgets(users[totalUsers].name, 50, stdin);
users[totalUsers].name[strcspn(users[totalUsers].name, "\n")] = 0;
printf("Username: ");
scanf("%s", users[totalUsers].username);
for (int i = 0; i < totalUsers; i++) {
if (strcmp(users[i].username, users[totalUsers].username) == 0) {
printf("Username taken\n");
return;
printf("Password: ");
scanf("%s", users[totalUsers].password);
users[totalUsers].isAdmin = asAdmin;
totalUsers++;
saveData();
printf("%s registered\n", asAdmin ? "Admin" : "Student");
int loginUser() {
char username[30], password[30];
printf("\nUsername: ");
scanf("%s", username);
printf("Password: ");
scanf("%s", password);
for (int i = 0; i < totalUsers; i++) {
if (strcmp(users[i].username, username) == 0 && strcmp(users[i].password, password) == 0) {
strcpy(currentUser, username);
isCurrentAdmin = users[i].isAdmin;
printf("Login success\n");
if (isCurrentAdmin) adminDashboard();
else studentDashboard();
return 1;
printf("Wrong credentials\n");
return 0;
void studentDashboard() {
int choice;
while (1) {
system("cls");
printf("\nStudent: %s\n", currentUser);
printf("1. Predict Admission\n");
printf("2. View Colleges\n");
printf("3. Logout\n");
scanf("%d", &choice);
if (choice == 1) predictAdmission();
else if (choice == 2) viewAllColleges();
else if (choice == 3) { currentUser[0] = 0; return; }
printf("\nPress Enter...");
getchar(); getchar();
void adminDashboard() {
int choice;
while (1) {
system("cls");
printf("\nAdmin: %s\n", currentUser);
printf("1. Add College\n");
printf("2. Edit College\n");
printf("3. Delete College\n");
printf("4. View Colleges\n");
printf("5. View Users\n");
printf("6. Logout\n");
scanf("%d", &choice);
if (choice == 1) addCollege();
else if (choice == 2) editCollege();
else if (choice == 3) deleteCollege();
else if (choice == 4) viewAllColleges();
else if (choice == 5) {
for (int i = 0; i < totalUsers; i++) {
printf("%d. %s - %s\n", i+1, users[i].name, users[i].isAdmin ? "Admin" : "Student");
else if (choice == 6) { currentUser[0] = 0; isCurrentAdmin = 0; return; }
printf("\nPress Enter...");
getchar(); getchar();
void addCollege() {
if (totalColleges >= MAX_COLLEGES) return;
printf("College Name: ");
getchar();
fgets(colleges[totalColleges].name, 50, stdin);
colleges[totalColleges].name[strcspn(colleges[totalColleges].name, "\n")] = 0;
printf("Cutoff: ");
scanf("%f", &colleges[totalColleges].cutoff);
totalColleges++;
saveData();
printf("Added\n");
}
void editCollege() {
viewAllColleges();
int n;
printf("Enter number to edit: ");
scanf("%d", &n); n--;
if (n >= 0 && n < totalColleges) {
printf("New cutoff: ");
scanf("%f", &colleges[n].cutoff);
saveData();
printf("Updated\n");
void deleteCollege() {
viewAllColleges();
int n;
printf("Enter number to delete: ");
scanf("%d", &n); n--;
if (n >= 0 && n < totalColleges) {
for (int i = n; i < totalColleges - 1; i++) colleges[i] = colleges[i + 1];
totalColleges--;
saveData();
printf("Deleted\n");
void viewAllColleges() {
if (totalColleges == 0) {
printf("No colleges\n");
return;
for (int i = 0; i < totalColleges; i++) {
printf("%d. %s - %.2f%%\n", i+1, colleges[i].name, colleges[i].cutoff);
void predictAdmission() {
float marks;
printf("Enter percentage: ");
scanf("%f", &marks);
printf("Eligible:\n");
int count = 0;
for (int i = 0; i < totalColleges; i++) {
if (marks >= colleges[i].cutoff) {
printf("%s\n", colleges[i].name);
count++;
if (count == 0) printf("No match\n");
else printf("Total: %d\n", count);