Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An educational Institution wants to maintain student information in computer sys

ID: 3662361 • Letter: A

Question

An educational Institution wants to maintain student information in computer system. To do this they planned to develop application software to perform the following operations by using C programming language.                              

A) A student record consisting of Name, Reg.no, Result.              

B) A student record can be inserted as First record or Last record or In-between the existing records.

C) A student record can be deleted as First record or Last record or In-between the existing records.

D) Display the student’s records.

Your work is to select a suitable DATA STRUCTURE to store the student records with proper justification and write a C code to perform the above operations.

(Note : For sub question B write only Insert as First record code and sub question C write only Delete as Last record code by making suitable assumptions).

Explanation / Answer

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<alloc.h>
typedef struct student
{
char regno[10];
char name[15];
char course[5];
char sub1[5];
char sub2[5];
char sub3[5];
char sub4[5];
char sub5[5];
int year;
struct student *link;
}node;
int i=0;
node *t,*x;
void cslist(node*);
void display(node*);
node* update(node*);
int find(node*);
void del(node*);
void main()
{
node *head;
int ch;
clrscr();
head=NULL;
do
{
printf(" Student Details Using Singly Linked List ");
printf(" Please Select an Operation To Perform");
printf(" 1. Create list of Students");
printf(" 2. Update Students");
printf(" 3. Delete student");
printf(" 4. Display Student Details");
printf(" 5. Exit");
printf(" Enter ur choice: ");
scanf("%d",&ch);
if(ch==5)
exit(0);
switch(ch)
{
case 1:
   head=(node*)malloc(sizeof(node));
   printf("Enter Student details ");
   cslist(head);
   break;
case 2:
   head=update(head);
   break;
case 3:
   del(head);
   break;
case 4:
   display(head);
   break;
default:
   printf(" Invalid Selection");
}
}while(1);
}
void cslist(node *head)
{
char ch;
printf("Enter RollNo of the Student ");
scanf("%s",head->regno);
printf("Enter Name of the Student ");
scanf("%s",head->name);
printf("Enter Course Student Selected ");
scanf("%s",head->course);
printf("Enter the subjects in the course Selected ");
scanf("%s",head->sub1);
scanf("%s",head->sub2);
scanf("%s",head->sub3);
scanf("%s",head->sub4);
scanf("%s",head->sub5);
printf("Enter the year ");
scanf("%d",&head->year);
printf("Do you want to add another student(y/n) ");
flushall();
scanf("%c",&ch);
if(ch=='y' || ch=='Y')
{
i++;
head->link=(node*)malloc(sizeof(node));
cslist(head->link);
}
else
head->link=NULL;
}
void display(node *head)
{
printf("--------------------------------------------------------------------- ");
printf("REGNO NAME COURSE SUB1 SUB2 SUB3 SUB4 SUB5 YEAR ");
printf("--------------------------------------------------------------------- ");
while(head->link!=NULL)
{
printf("%s %s %s %s %s %s %s %s %d ",head->regno,head->name,head->course,head->sub1,head->sub2,head->sub3,head->sub4,head->sub5,head->year);
head=head->link;
}
printf("%s %s %s %s %s %s %s %s %d ",head->regno,head->name,head->course,head->sub1,head->sub2,head->sub3,head->sub4,head->sub5,head->year);
}
node* update(node* head)
{
node *temp;
int ch;
clrscr();
printf("Add Student ");
printf("1.Add in begining ");
printf("2.Add in between ");
printf("3.Add at End ");
printf("Enter choice ");
scanf("%d",&ch);
temp=(node*)malloc(sizeof(node));
printf("Enter the student RegNo: ");
scanf("%s",temp->regno);
printf("Enter the student Name ");
scanf("%s",temp->name);
printf("Enter the student course ");
scanf("%s",temp->course);
printf("Enter the subjects ");
scanf("%s",temp->sub1);
scanf("%s",temp->sub2);
scanf("%s",temp->sub3);
scanf("%s",temp->sub4);
scanf("%s",temp->sub5);
printf("Enter year ");
scanf("%d",&temp->year);
switch(ch)
{
case 1:
   if(head==NULL)
   {
   head=temp;
   temp->link=NULL;
   }
   else
   {
   temp->link=head;
   head=temp;
   return(head);
   }
   break;
case 2:
   if(find(head))
   {
   temp->link=t->link;
   t->link=temp;
   return(head);
   }
   else
   {
   printf("Invalid Selection");
   free(temp);
   }
   break;
case 3:
   temp->link=NULL;
   t=head;
   while(t->link!=NULL)
   t=t->link;
   t->link=temp;
   break;
default:
   printf("Invalid choice");
}
return(head);
}
int find(node* head)
{
int str=0;char regno[10];
t=head;
x=head;
printf("Enter the regno to find: ");
scanf("%s",regno);
if(head!=NULL)
{
do
{
str=strcmp(t->regno,regno);
if(str==0)
{
return 1;
}
x=t;
t=t->link;
}while(t->link!=NULL);
str=strcmp(t->regno,regno);
if(str==0)
{
return 1;
}
}
else
return 0;
return 1;
}
void del(node* head)
{
if(find(head))
{
if(head==t)
{
head=t->link;
free(t);
}
else if(t->link==NULL)
{
x->link=t->link;
free(t);
}
}
else
printf("Invalid Reg No");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote