Store Details of a Student in Linked list
Store Details of a Student in Linked list

C++ Store Details of a Student in Linked list

Store Details of a Student in Linked list

Hello in this program you will learn how to Store Details of a Student in Linked list, also we learn to process them with an Action Button.

Thank you for reading this post, don't forget to subscribe!

Before understanding this Program, you should have knowledge about the following topics.

Circular Linked list

Linked list simple program

C++ Program to Store Details

#include <iostream>

using namespace std;

class sNode{
public:
string Name;
string rollNo;
sNode *next;

sNode(){
next=nullptr;
}
};

class LinkedList{
sNode *head;
public:

LinkedList(){
head = nullptr;
}

void insert_at_beginning(string name, string rNo ){
sNode *temp = new sNode();
temp->Name = name;
temp->rollNo = rNo;
temp->next = head;
head = temp;
}

void print(){
if (head == NULL){
cout<<"List is empty"<<endl;
}
else{
sNode *temp = head;
cout<<"Linked List: "<<endl;
cout<<"Name\t\tRollNo"<<endl;

while (temp != NULL){
cout<<temp->Name<<"\t\t"<<temp->rollNo<<endl;
temp = temp->next;
}
}
} 
};

int main()
{

cout<<"1 to Insert at the beginning"<<endl;
cout<<"2 to Display"<<endl;
cout<<"3 to Exit"<<endl;

int choice,v,p;
string n,r;
LinkedList ll;

do {
cout<<"\nEnter Your Choice: ";
cin>>choice;
switch (choice)
{
case 1:
cout<<"Enter Name: ";
cin>>n;
cout<<"Enter RollNO: ";
cin>>r;
ll.insert_at_beginning(n,r);
break;
case 2:
ll.print();
break;

}
} while (choice != 3);

cout<<"program Ends";
return 0;
}

Student DataBase system in Cpp

Output

Here the program will provide you 3 Options.

[alert-announce]

1 to Insert at the beginning

2 to Display

3 to Exit

Enter Your Choice:

[/alert-announce]

Now we’re giving commands to the executive programs.

[alert-success]

Enter Your Choice: 1

Enter Name: JACK

Enter RollNO: 12

[/alert-success]

After submitting it will represent choice, now we’ll enter our choice again for Displaying.

[alert-announce]

Enter Your Choice: 2

Linked List:

Name    RollNo

JACK        12

[/alert-announce]

After Displaying the data, again it will provide an Option for next. But we saw there is a 3 option for Exit, so we choose 3.

[alert-success]

Enter Your Choice: 3

Program Finished

[/alert-success]

Red represents User Inputted Value.

♥Blue Represent compiler Output.

When you enter option 2, then it will displayed you a msg like “List is Empty

C++ Program to Store Information of a Student in a Linked list

Store Details of a Student in Linked list
Store Details of a Student in Linked list

SAURABHNISSA

Saurabh Nissa

This is SaurabhNissa, Owner of Thesmolt.com I'm Graduated from Magadh University in 2019 with 75%. Currently, I'm working on my Personal educational website for teaching Programming language free of Coast, and want to provide a Full setup for Specially BCA student