/*Title : Creating Student Database Using Singly linked list */
#include<stdio.h>
#include<conio.h>
struct Student
{
int roll;
char name[30];
float marks;
struct Student *next; //Self referential pointer...
};
typedef struct Student Node;
void Linkfloat()
{
float a=0,*b; //To create link of float to some compiler ...
b=&a;
a=*b;
}
void Display(Node *head)
{
Node *p;
int i;
if(head==NULL)
{
printf("
There is no records in database.
");
}
else
{
p=head;
for(i=0;i<80;i++)
{
printf("-");
}
printf("
Updated Student Database
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
printf("Roll No. Name Marks
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
while(p!=NULL)
{
printf("%d %s %0.2f",p->roll,p->name,p->marks);
printf("
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
flushall();
p=p->next; //Go to next node...
}
}
}
void DReverse(Node * head)
{
Node *p;
int i;
if(head==NULL)
{
printf("
There is no records in database.
");
}
else
{
p=head;
if(p->next!=NULL)
{
DReverse(p->next); //Recursive call...
}
printf("%d %s %0.2f",p->roll,p->name,p->marks);
printf("
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
flushall();
printf("
");
}
}
Node* Create(Node *head)
{
int n,i;
Node *nn,*p;
printf("
How many Entries to Create Database???
");
scanf("%d",&n);
for(i=0;i<n;i++)
{
if(head==NULL)
{
nn=(Node*)malloc(sizeof(Node)); //Creating first node...
printf("
Enter Roll No. , Name & Marks
");
scanf("%d",&(nn->roll));
flushall();
gets(nn->name);
scanf("%f",&(nn->marks));
nn->next=NULL; //Set next to NULL...
head=nn;
}
else
{
p=nn=head;
while(nn->next!=NULL)
{
nn=nn->next;
}
nn->next=(Node*)malloc(sizeof(Node)); //Creating further nodes...
nn=nn->next;
printf("
Enter Roll NO.,Name & Marks
");
scanf("%d",&(nn->roll));
flushall();
gets(nn->name);
scanf("%f",&(nn->marks));
nn->next=NULL;
nn=p;
}
}
return head;
}
Node* Insert(Node *head)
{
int ch,r;
char ans;
Node *p,*nn,*q;
do
{
printf("
Whwre do you want to enter new entry???
");
printf("
1.At the Begining
2.At the middle
3.At the end
");
printf("
Enter your choice:
");
scanf("%d",&ch);
switch(ch)
{
case 1:
/* Insert at Begining */
p=head;
nn=(Node*)malloc(sizeof(Node));
printf("
Enter Roll NO., Name & Marks
");
scanf("%d",&(nn->roll));
flushall();
gets(nn->name);
scanf("%f",&(nn->marks));
nn->next=NULL;
nn->next=p;
head=nn; //set first node as head...
printf("
Entry is Created successfully.
");
Display(head);
break;
case 2:
/* Insert at Middle */
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
}
else
{
printf("
After which Roll NO. You want to insert new Data???
");
scanf("%d",&r);
p=head;
while(p->roll!=r && p->next!=NULL)
{
p=p->next; //Go upto that roll no....
}
if(p->roll!=r)
{
printf("
There is no such entry.
");
}
else
{
nn=(Node*)malloc(sizeof(Node));
printf("
Enter Roll NO.,Name & Marks
");
scanf("%d",&(nn->roll));
flushall();
gets(nn->name);
scanf("%f",&(nn->marks));
nn->next=NULL;
q=p->next;
p->next=nn;
nn->next=q;
printf("
Entry is Created successfully.
");
Display(head);
}
}
break;
case 3:
/* Insert at end */
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
}
else
{
p=head;
nn=(Node*)malloc(sizeof(Node));
printf("
Enter Roll NO.,Name & Marks
");
scanf("%d",&(nn->roll));
flushall();
gets(nn->name);
scanf("%f",&(nn->marks));
nn->next=NULL;
while(p->next!=NULL)
{
p=p->next; //Go upto last node...
}
p->next=nn;
printf("
Entry is Created successfully.
");
Display(head);
}
break;
}
printf("
Do you want to Insert more data(Y/N)???");
flushall();
scanf("%c",&ans);
}while(ans=='y' ans=='Y');
return head;
}
Node* Delete(Node* head)
{
Node *p,*q,*r;
char ans;
int ch,n;
do{
printf("
Which Entry you want to Delete???
");
printf("
1.First
2.Middle
3.End
");
scanf("%d",&ch);
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
}
else
{
switch(ch)
{
case 1:
/*Delete first node */
p=head;
head=head->next; //Set second node as head...
free(p);
printf("
First entry is deleted.
");
Display(head);
break;
case 2:
/*Delete middle Node*/
p=head;
printf("
Enter roll no. which you want to delete:
");
scanf("%d",&n);
while((p->next)->roll!=n && p->next->next!=NULL)
{
p=p->next; //Go upto -1 node which you want to delete...
}
if(p->next->next==NULL)
{
printf("
There is no such entry.
");
}
else
{
q=p->next;
r=q->next;
p->next=r;
free(q); //Delete that node...
printf("
Entry is deleted.
");
Display(head);
}
break;
case 3:
/* Delete last node */
p=head;
while(p->next->next!=NULL)
{
p=p->next; //Go upto -1 node which you want to delete...
}
q=p->next;
free(q); //Delete last node...
p->next=NULL;
printf("
Last entry is deleted.
");
Display(head);
break;
}
}
printf("
Do you want to delete more data(Y/N)???
");
flushall();
scanf("%c",&ans);
}while(ans=='y' ans=='Y');
return head;
}
Search(Node *head)
{
Node *p;
int r,cnt=0;
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
}
else
{
p=head;
printf("
Enter roll no. which you want to Search:
");
scanf("%d",&r);
while(p->roll!=r && p->next!=NULL) //Search for roll no...
{
p=p->next;
cnt++;
}
if(p->roll!=r)
printf("
There is no such entry.
");
else
{
printf("
Roll NO. %d is at %d th Position.",r,(cnt+1));
printf("
Roll No. Name Marks
");
printf("%d %s %0.2f",p->roll,p->name,p->marks);
}
}
}
Modify(Node * head)
{
Node *p;
int r;
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
}
else
{
p=head;
printf("
Enter the Roll no. whose data you want to modify:
");
scanf("%d",&r);
while(p->roll!=r && p->next!=NULL)
{
p=p->next;
}
if(p->roll!=r)
{
printf("
Thre is no such record in Database.
");
}
else
{
printf("
Entered roll no's Data is:
");
printf("Roll No. Name Marks
"); //Displaying Data who is going to modify....
printf("%d %s %f",p->roll,p->name,p->marks);
printf("
Enter New roll no ,New name & Marks for this entry:
");
scanf("%d",&p->roll);
flushall();
gets(p->name); //Enter new data...
scanf("%f",&(p->marks));
printf("
Entered New Data is:
");
printf("Roll No. Name Marks
");
printf("%d %s %f",p->roll,p->name,p->marks);
Display(head);
}
}
}
Count(Node *head)
{
Node *p;
int cnt=0;
if(head==NULL)
{
printf("
Yet database is not created.");
printf("
Database is empty.
");
printf("
First Create Database.
");
printf("
There are 0 records in Database.
");
}
else
{
p=head;
while(p->next!=NULL)
{
p=p->next;
cnt++; //Counting records...
}
printf("
There are %d records in Database.
",(cnt+1));
}
}
void main()
{
int ch,i;
char op;
Node *head;
head=NULL;
printf("
*----------Studednt Database-----------*
");
do
{
printf("
Menu
1.Create Database
2.Insert
3.Delete
4.Search
5.Modify
6.Display
7.Display Reverse
8.Count Records
9.Exit
");
printf("
Enter your choice
");
scanf("%d",&ch);
switch(ch)
{
case 1:
head=Create(head); //Call to Create...
break;
case 2:
head=Insert(head); //Call to Insert...
break;
case 3:
head=Delete(head); //Call to Delete...
break;
case 4:
Search(head); //Call to Search...
break;
case 5:
Modify(head); //Call to Modify...
break;
case 6:
Display(head); //Call to Display...
break;
case 7:
for(i=0;i<80;i++)
{
printf("-");
}
printf("
Updated Student Database
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
printf("Roll No. Name Marks
");
for(i=0;i<80;i++)
{
printf("-");
}
printf("
");
DReverse(head); //Call to displaying reversre...
break;
case 8:
Count(head); //Call to counting records...
break;
case 9:
exit(); //Exit...
default :
printf("
You entered wrong choice.
");
}
printf("
Do you want to Exit(Y/N)???
");
flushall();
scanf("%c",&op);
}while(op=='n' op=='N');
}
Add another pointer to the nodes for the previous node: struct node { struct node *next; struct node *previous; void *data; }; typedef struct node node; Then change the logic for insertion and removal to make sure you set the previous pointer as well as the next one.
It's not that one is better than the other. They are used in different circumstances. A linear linked list is used like an array, with the added benefits of random insertion/removal of elements, etc. A circular linked list is often used as a buffer where one portion of the program produces data and another consumes it, such as in communications.
An ER diagram for a school management system typically includes entities such as Student, Teacher, Course, Classroom, and Enrollment. Relationships between these entities can be depicted using cardinality and participation constraints to show how they are connected (e.g., a student enrolls in courses taught by teachers in specific classrooms). The ER diagram serves as a visual representation of the database schema for the school management system.
Data redundancy can be reduced by normalizing the database to eliminate duplicate data, creating relationships between tables, and using foreign keys to link related information. Using data validation rules and constraints can also help prevent redundant data from being entered into the database. Implementing a master data management strategy can centralize and standardize data, reducing redundancy across different systems.
Yelling at a student is generally not an effective or appropriate way to address behavior or academic issues. Teachers should strive to maintain a respectful and supportive classroom environment, using positive reinforcement and communication to address concerns with students.
Which of the following data structures can be randomly accessed giving loc?A. linked list implemented using arrayB. singly linked listC. double linked listD. both single and double linked listThe answer is A.
Add another pointer to the nodes for the previous node: struct node { struct node *next; struct node *previous; void *data; }; typedef struct node node; Then change the logic for insertion and removal to make sure you set the previous pointer as well as the next one.
Evaluating a Polynomial expression using a singly linked list visit : http://myfundatimemachine.blogspot.in/2012/06/polynomial-evaluation-in-c.html
transpiration
The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.
A singly linked list is a linked list which only provides links in "one direction". Using a metaphor, a singly linked list is a one way street, while a doubly linked list is a two way street. Once you move forward in a singly linked list, there is no way to go backwards unless you kept your reference/pointer from before. A singly linked list would look like this: start ----> node1---->node2---->node3 ----> NULL You will see that node2 only has a link forward to node3 - it does not have a link backwards to node1, even though node1 has a link forwards to node2. To prevent us from permanently losing access to portions of the linked list, we generally keep a reference/pointer to "start". A doubly linked list would have twice the number of pointers/references as a singly linked list - making it very inefficient to store small datatypes. On the other hand, it would be possible to move both forwards and backwards with a doubly linked list because you have links pointing both forwards and backwards.
homa
A relational database is a database that contains tables linked by common fields. These common fields are used to establish connections between the tables and to retrieve related data across multiple tables using queries.
mini project data structure
To determine if you have federal student loans, you can log in to the National Student Loan Data System (NSLDS) using your FSA ID. This database will show all federal student loans you have taken out.
Relational database: Relational database means a collection data stored in different tables and each table are linked together by using primary key and foreign key. In relational database, data can be accessed from one table to another without reorganising the required table. The relational database was invented by E. F. Codd at IBM in 1970.
what can be achieved from the database using reports