Create three database using header linked
Student (Roll No, Name, Branch ID, CGPA)
University (University ID, University Name, University Location, Year of start)
Branch (Branch ID, University ID, Branch Name)
Implement the following modules/ sub-modules using menu driven approach:
-> ADD/ MODIFY/DELETE/UPDATE using key values in any of the databases as per requirement.
-> Display the student details who are reading at a specific University with branch CSE.
#include<stdio.h>
#include <stdlib.h>
struct Student {
int Roll_No;
char name[50];
int Branch_ID;
double CGPA;
};
struct University{
int university_id;
char university_name[50];
char location[50];
int year_of_start;
};
struct Branch{
int Branch_ID;
int university_id;
char branch_name[60];
};
struct Details{
struct University uni;
struct Student stu;
struct Branch bra;
struct Details * next;
};
void push(struct Details** head)
{
struct Details * newNode = (struct Details*)malloc(sizeof(struct Details));
struct Details d;
struct Student s;
printf("Enter student details:\n");
printf("Enter the student roll no:\n");
scanf("%d",&s.Roll_No);
printf("Enter the student name:\n");
scanf("%s", &s.name);
printf("Enter the Branch ID:\n");
scanf("%d", &s.Branch_ID);
printf("Enter the CGPA:\n");
scanf("%d", &s.CGPA);
struct University un;
printf("Enter university details:\n");
printf("Enter university id:");
scanf("%d", &un.university_id);
printf("Enter university name:\n");
scanf("%s", &un.university_name);
printf("Enter university location:\n");
scanf("%s", &un.location);
printf("Enter university year of start:\n");
scanf("%d", &un.year_of_start);
struct Branch br;
printf("Enter branch details:\n");
printf("Enter branch id:\n");
scanf("%d", &br.Branch_ID);
printf("Enter branch name\n");
scanf("%s", &br.branch_name);
printf("Enter university id\n");
scanf("%d", &br.university_id);
newNode->uni = un;
newNode->stu = s;
newNode->bra = br;
newNode->next = (*head);
(*head) = newNode;
}
void display(struct Details* node){
while(node != NULL){
printf("The student details:\n");
printf("Name: %s\n", node->stu.name);
printf("Roll No: %d\n", node->stu.Roll_No);
printf("Branch ID: %d\n", node->stu.Branch_ID);
printf("CGPA: %d\n", node->stu.CGPA);
printf("The University details:\n");
printf("ID: %d\n", node->uni.university_id);
printf("Name: %s\n", node->uni.university_name);
printf("Location %s\n", node->uni.location);
printf("Year of start %d\n", node->uni.year_of_start);
printf("The Branch Details:\n");
printf("Branch ID: %d\n", node->bra.Branch_ID);
printf("Branch Name: %s\n", node->bra.branch_name);
printf("University ID: %d\n", node->bra.university_id);
node = node->next;
}
}
int main(){
//Testing the three database
struct Details * head = NULL;
push(&head);
push(&head);
display(head);
}
Comments
Leave a comment