F Simple Linked List program example in C++ | CodeTheta

Simple Linked List program example in C++

June 14, 2017

This is a simple Linked List program which contains three nodes. First, Second, Third .Each node have data part and next part. First, Second, Third nodes data part contain 30,40,50 value respectively.

Code :
#include<iostream>
#include<stdlib.h>
using namespace std;
struct Node 
{
  int data;
  struct Node *next;
};
int main()
{
  struct Node* First = NULL;
  struct Node* Middle = NULL;
  struct Node* Last = NULL;
  First = (struct Node*)malloc(sizeof(struct Node)); 
  Middle = (struct Node*)malloc(sizeof(struct Node));
  Last = (struct Node*)malloc(sizeof(struct Node));
  First->data = 30;
  First->next = Middle;
  Middle->data = 40;
  Middle->next = Last;
  Last->data = 50;
  Last->next = NULL;
  cout<<"\nFirst :"<<First->data;
  cout<<"\nMiddle :"<<Middle->data;
  cout<<"\nLast :"<<Last->data;
  return 0;
}

Output :
First : 30
Middle : 40
Last : 50

IDE Used To Test This Code : DEV C++.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment

PRODUCTS

LISTS OF PRODUCTS

SERVICES

SKILLS
SOFTWARE DEVELOPMENT
WEBSITE DEVELOPMENT
WEB HOSTING
BULK SMS SERVICE
SEO SERVICE
ANDROID APPS
QR CODE / BARCODE
HARDWARE SERVICE
OUR WORK AREA