#include<stdio.
h>
#include<stdlib.h>
#include<string.h>
struct node
{
int roll;
char name[50];
float fee;
struct node *next;
};
struct node *head=NULL;
void addstudent()
{
struct node *newnode,*temp;
newnode=(struct node*)malloc(sizeof(struct node));
printf("Enter Roll Number : ");
scanf("%d",&newnode->roll);
printf("Enter Student Name : ");
scanf(" %[^\n]",newnode->name);
printf("Enter Fee Amount : ");
scanf("%f",&newnode->fee);
newnode->next=NULL;
if(head==NULL)
{
head=newnode;
}
else
{
temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newnode;
}
printf("Record Added Successfully\n");
}
void display()
{
struct node *temp;
if(head==NULL)
{
printf("No Records Found\n");
return;
}
temp=head;
printf("\nRoll\tName\t\tFee\n");
while(temp!=NULL)
{
printf("%d\t%s\t\t%.2f\n",temp->roll,temp->name,temp-
>fee);
temp=temp->next;
}
}
void search()
{
int roll;
struct node *temp;
printf("Enter Roll Number to Search : ");
scanf("%d",&roll);
temp=head;
while(temp!=NULL)
{
if(temp->roll==roll)
{
printf("Record Found\n");
printf("Name : %s\n",temp->name);
printf("Fee : %.2f\n",temp->fee);
return;
}
temp=temp->next;
}
printf("Record Not Found\n");
}
void update()
{
int roll;
struct node *temp;
printf("Enter Roll Number to Update : ");
scanf("%d",&roll);
temp=head;
while(temp!=NULL)
{
if(temp->roll==roll)
{
printf("Enter New Fee Amount : ");
scanf("%f",&temp->fee);
printf("Fee Updated Successfully\n");
return;
}
temp=temp->next;
}
printf("Record Not Found\n");
}
void collectfee()
{
int roll;
struct node *temp;
printf("Enter Roll Number : ");
scanf("%d",&roll);
temp=head;
while(temp!=NULL)
{
if(temp->roll==roll)
{
temp->fee=0;
printf("Fee Collected Successfully\n");
return;
}
temp=temp->next;
}
printf("Record Not Found\n");
}
void deleterec()
{
int roll;
struct node *temp,*prev;
printf("Enter Roll Number to Delete : ");
scanf("%d",&roll);
temp=head;
prev=NULL;
while(temp!=NULL)
{
if(temp->roll==roll)
{
if(prev==NULL)
{
head=temp->next;
}
else
{
prev->next=temp->next;
}
free(temp);
printf("Record Deleted Successfully\n");
return;
}
prev=temp;
temp=temp->next;
}
printf("Record Not Found\n");
}
int main()
{
int ch;
while(1)
{
printf("\n--- Fee Collection System ---\n");
printf("[Link] Student\n");
printf("[Link] Records\n");
printf("[Link] Student\n");
printf("[Link] Fee\n");
printf("[Link] Fee\n");
printf("[Link] Record\n");
printf("[Link]\n");
printf("Enter Choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
addstudent();
break;
case 2:
display();
break;
case 3:
search();
break;
case 4:
update();
break;
case 5:
collectfee();
break;
case 6:
deleterec();
break;
case 7:
exit(0);
default:
printf("Invalid Choice\n");
}
}
return 0;
}