Pages

Friday, December 6, 2013

file reading using array

// filing.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include<fstream>
#include<string>
#include<iostream>
using namespace std;


int main(){


ifstream is;//made an object of input file stream to read from file using array

char character[100];


is.open("ReadMe.txt");
is.getline(character,100,'\n');

while(!is.eof() && !is.fail()){
cout<<character;
is.getline(character,100,'\n');
}
is.close();
cout<<endl;
return 0;
}

Thursday, December 5, 2013

file reading character by character in C++




//#include "stdafx.h" used when compiling in Visual Studio 2012

#include<fstream>
#include<iostream>
using namespace std;


int main(){


ifstream is;//made an object of input file stream to read from file character by character

char character;

is.open("myfile.txt");//make a file of any name instead of myfile.txt in compiler directory

is>>character;
while(!is.eof() && !is.fail()){
cout<<character;
is>>character;
}
is.close();
cout<<endl;
return 0;
}

Wednesday, July 31, 2013

Linked List IN Classes C++

/*
QUESTION 
IMPLEMENT following functions by using linked list in classes

1 to insert a node in link list at head
2 to insert a node in link list at tail: 
3 to display link list: 
4 to count how many times an integer occurs in your link list:
5 to see node's data by entering its number:  
6 to delete complete link list and head of link list get value NULL
7 to pop your link list: 


CODE:

*/


#include<iostream>
using namespace std;
class link{
protected:
int id;
int other;
link * next;
link * previous;
public:
    link(){
next = NULL;
previous = NULL;
}
//----------------------------
int get_id(){

return id;
}
//----------------------------
link * get_data(){

link *p = new link;
cout<<"\nEnter ID: ";cin>>p->id;
cout<<"\nEnter oter: ";cin>>p->other;

return p;
}
//----------------------------
void insert_link_at_head(link **h,link **t,link *temp){
if((*h)==NULL && (*t)==NULL){
(*h)=temp;
(*t)=temp;
}
        else
temp->next = (*h);
(*h)->previous = temp;
(*h)=(*h)->previous;
}
//-----------------------------
void insert_link_at_tail(link **h,link **t,link *temp){
if((*h)==NULL && (*t)==NULL){
(*h)= temp;
(*t)=temp;
}
        (*t)->next = temp;
temp->previous = (*t);
(*t)=temp;

}
//------------------------------
int count(link *h,int id){
link *p = h;
int count = 0;
while(p!=NULL){

if(p->id == id){
count++;
}
p = p->next;
}
return count;
}
//------------------------------
void display(link *h){

link *p = h;

while(p != NULL){
cout<<"\nID is : "<<p->id;
cout<<"\nOther is: "<<p->other;
p = p->next;
}
}
//------------------------------
link  * Get_nth(link *h, int id){
int count = 0;
link *ptr = h;
while(ptr != NULL){

if(count == id-1){
return ptr;
}
ptr = ptr->next;
count ++;
}

}

//------------------------------
void DeleteLIST(link**h){
while((*h) != NULL ){

link *temp = (*h);
(*h) = (*h)->next;
delete temp;
}


}
//------------------------------
link * POP(link **h){
link *p = (*h);
if((*h)->next ==NULL){
cout<<"\nID of node which is being deleted: "<<(*h)->id;
delete (*h);
(*h) = NULL;
return (*h);
}
else
{
cout<<"\nID of node which is being deleted: "<<(*h)->id;
(*h)= (*h)->next;
delete p;
return (*h);


}
}

//void InsertNth(link **h,link *t,int index){
//link *ptr = (*h);

/*if(index == 0){
Ninsert_link_at_head((h),t);
}

 
while(ptr != NULL){

 
for(int i=0;i<index;i++){
if(ptr->next != NULL)
{
ptr = ptr->next;
}

 }
 if(ptr == (*h))
 Ninsert_link_at_head((h),t);
 else if(ptr== NULL)
 Ninsert_link_at_tail((h),t);
 
ptr->previous->next = t;
t->next = ptr;
t->previous = ptr->previous;
ptr->previous = t;
break;

 }
 

 
}

 
void Ninsert_link_at_head(link **h,link *temp){
if((*h)==NULL ){

 temp->next =(*h);
 (*h)->previous = temp;
 (*h)= temp;
 (*h)->previous = NULL;
 } 
}*/

};






int main(){

link *head = NULL;
link *tail = NULL;
link *temp = NULL;

link obj;

while(1){
cout<<"\nEnter ";
cout<<"\n1 to insert a node in link list at head: ";
cout<<"\n2 to insert a node in link list at tail: ";
cout<<"\n3 to display link list: ";
cout<<"\n4 to count how many times an integer occurs in your link list:";
cout<<"\n5 to see node's data by entering its number:  ";
cout<<"\n6 to delete complete link list and head of link list get value NULL: ";
cout<<"\n7 to pop your link list: ";


cout<<"\n\n\n";

int opt;
cin>>opt;
switch(opt){
case 1:
{
temp = obj.get_data();
obj.insert_link_at_head(&head,&tail,temp);
}
break;
case 2:
{
temp = obj.get_data();
obj.insert_link_at_tail(&head,&tail,temp);
}
break;
case 3:
{
obj.display(head);
}
break;
case 4:
{
cout<<"\nEnter ID which you want o check in the link list: ";int id;
cin>>id;

cout<<"\n :"<<id<<":  Occurs : "<<obj.count(head,id)<<": times \n";
}
break;
case 5:
{
cout<<"\nEnter the node no whose data you want: ";
int id; cin>>id;
link *ptr;
ptr = obj.Get_nth(head,id);
//obj.display(ptr);
cout<<"\n ID is: "<<ptr->get_id();
}
break;
case 6:
{
obj.DeleteLIST(&head);
cout<<"\nLINked list deleted: \n";
cout<<head;
}
case 7:
{
obj.POP(&head);
}
break;
case 8:
{

}
break;

default:
break;

}
}

return 0;
}

Wednesday, July 24, 2013

Public Single Inheritance Using Polymorhism implementation in c++

/*
QUESTION:


CODE:

*/

Polymorphism Public Single Inheritance code C++

/*
QUESTION:
                                           (Polymorphism)
 
 
Write a program to prepare the result of students by using Public -- Single Inheritance. The base



class is "std_info" and the derived class is "std_result". Major Attributes of both classes are as under:

(Add the other functionality).


std_info

private:
int reg_no; // To store registration # of student

char name[15]; // To store name of student

char address[50]; // To store address of

student


public:
void input_info(void); //Function to input

information

void print_info (void); //Function to print

information
///////////////////////////////////////////////////////////////////////
class std_result

private:
float sub1; //Marks of subject 1

float sub2; //Marks of subject 2

float sub3; //Marks of Subject 3

float average; //Average Marks

(sub1+sub2+sub3)/3

float total; //Total Marks (sub1+sub2+sub3)


public:
void input_info(); // Input marks of students

void print_info(); //Printing result card
 
Ø  In main, create an object "student" of "std_result".

Ø  Now create pointer "ptr" to std_info to manipulate all the student information (Note: You are



authorised to use only the pointer to std_info) i.e.

a. First get basic student information.

b. Next get details marks of student as input.

c. Finally print all the student information and his result card.
 




CODE:
*/

#include<iostream>
using namespace std;

class std_info{
int reg_no;
char name[15];
char address[50];

public:
 virtual void input_info(void){
  cout<<"\nEnter Registeration no: ";cin>>reg_no;

  cout<<"\nEnter name: ";
   cin.ignore();
  cin.getline(name,15,'\n');


  cout<<"\nEnter Address: ";
  cin.ignore();
  cin.getline(address,50,'\n');


 }
  virtual  void print_info(void){
  cout<<"\n REgisteration no is: "<<reg_no;
  cout<<"\nName is: "<<name;
  cout<<"\nAddress is : "<<address<<endl;
 }

};
class std_result: public std_info{
float sub1;
float sub2;
float sub3;
float average;
float total;

public:
 void input_info(){
cout<<"\nEnter marks of subject 1: ";cin>>sub1;
cout<<"\nEnter marks of subject 2: ";cin>>sub2;
cout<<"\nEnter marks of subject 3: ";cin>>sub3;
 }
 void print_info(){

  average=(sub1+sub2+sub3)/3;
  total = sub1+sub2+sub3;
cout<<"\nAverage marks are: "<<average;
cout<<"\nTotal marks are: "<<total<<endl;
 }

};


int main(){
std_result student;

std_info *ptr;
std_info *ptr1 = new std_info;
ptr1->input_info();

ptr = &student;
ptr->input_info();
ptr1->print_info();

ptr->print_info();

return 0;
}

Tuesday, July 16, 2013

Garage Management in C++

/*
QUESTION:
You are hired by a Garage owner to design a Garage Management System (GMS). To avoid the
Traffic jams, yous GMS will tell the new customers coming to the garage at the garage entrance
how many places are left in the Garage and whether there is place for their car in the Garage or
not (You GMS will be also conveying this information to Garage owner as well). To design this
Garage Management System you will write two classes those are Car and Garage classes.
Details of the functionality desired by these classes is dictated by the GMS requirements. So
1. Write a class named as ‘Car’ having following Attributes:
● ‘make’ of type string
● ‘car_model’ of type string
● ‘reg_no’ of type string
● ‘color’ of type string
● ‘year’ of type int
Car Class will provide following interface.
i. Write a constructor to initialize the attributes of car.
ii. Write init (string ,string, string, string, int ) function to initialize the attributes of
car.
iii. Write a destructor for car class
2. Now write class Garage of your GMS having the following attributes
● ‘name’ of type string
● ‘index’ of type int
● ‘capacity’ of type int
● Array of objects of ‘car’ class with maximum size equals to ‘capacity’
Provide following functionality/interface for Garage class
i. Write a constructor for class ‘Garage’ to initialize its attributes. Initially consider
that the Garage has capacity of 10 cars.
ii.  IsEmpty(): Returns true if garage is empty and false otherwise
iii.  IsFull(): Returns true if garage is full and false otherwise.
iv.  Push(car c): Implement that function to park a new car c in garage, considering
that the garage is not full.
v.  Find(string reg): Function should return true if that car is parked in garage and
false otherwise
vi.  Remove(string reg): Function should remove the car object from garage having
reg_no equals to the given in the parameter. Returns true if car is successfully
removed and false otherwise and display messages accordingly.
(Hint: You can compare two strings using == equality operator in the same way
you compare two numerical variables)
vii. Display(): Displays all the cars parked in garage currently.
3. Menu should looks like as follows:
Exercise 7.2:
1. Add Car in Garage
2. Remove car from garage
3. Display parked cars
4. Find car
5. Check if garage is full

CODE:

*/


#include<iostream>
#include<string>
using namespace std;

/////////////////////////////CAR CLASS ////////////////////////////////////
class car{

string make;
string car_model;
string reg_no;
string color;
int year;
public:

car(){
make = "";
car_model= "";
reg_no= "";
color = "";
}
void init(){
cout<<"\nEnter Make: "; cin>>make;

cout<<"\nEnter Car MOdel: ";cin>>car_model;

cout<<"\nEnter COLOR: ";cin>>color;

cout<<"\nEnter Registration no: "; cin>>reg_no;

cout<<"\nEnter Year: "; cin>>year;
}
string getReg(){
return reg_no;
}
void cDisplay(){
cout<<make<<endl;
cout<<car_model<<endl;
cout<<reg_no<<endl;
cout<<color<<endl;
}
~car(){
//cout<<"\n\nDEstructor called\n";
}


};

/////////////////////////////////GARAGE CLASS ////////////////////////////

class Garage{
string name;
int index;
const int capacity;
car  *ptr;
public:
Garage():capacity(2){
name = " ";
//index = 0;this can also be done if we skip setting index
ptr = new car[capacity];

}
void seti()//set index
{
index=0;
}
bool IsEmpty(){
if(index != capacity)
return true;
else 
return false;
}
bool IsFull(){
if(index == capacity)
return true;
else 
return false;
}
void push(){
bool x;
x = IsEmpty();
if (x==1){
cout<<"\n\nCar can be parked\n";
ptr[index].init();
index++;
}
else 
cout<<"\n Garage is Full: \n";
}
bool Find(string reg){
for(int i=0; i<capacity;i++){
if(ptr[i].getReg() == reg){
cout<<"\nCar found \n";
return true;
}



}
return false;
}
bool Remove(string reg){
for(int i=0; i<10;i++){
if(ptr[i].getReg() == reg){
cout<<"\nCar found  and removed\n";
--index;
return true;
}
}
return false;
}
void Display(){
for (int i=0;i<index;i++){
ptr[i].cDisplay();
}


}

};


///////////////////////MAIN//////////////////////////////
void main(){
Garage obj1;
obj1.seti();
while(1){
int opt;
cout<<"\n******************************************\n";
cout<<"\nEnter \n";

cout<<"1. Add car in GARAGE\n";

cout<<"2. Remove car from GARAGE\n";

cout<<"3. Display parked cars\n";

cout<<"4. FInd a car\n";

cout<<"5. Check If garage is ful\n";
cout<<"-------------------------------------------\n";




int year;

string col,make,reg,model; 

cin>>opt;
switch(opt){

case 1:
{

obj1.push();

}
break;
case 2:
{
cout<<"\nEnter registration no of the car to be removed: ";
cin>>reg;

obj1.Remove(reg);
}
break;
case 3:
obj1.Display();
break;
case 4:
{cout<<"\nEnter registeration no: ";
cin>>reg;
bool a = obj1.Find(reg);
if (a==1)
cout<<"\nCar found  \n";
}
break;
case 5:
{
bool a = obj1.IsFull();
if (a==1){
cout<<"\nGarage is full  \n";
}
else
cout<<"\nGArage is not full \n";

}

break;
default:

break;

}
}



}

Thursday, July 11, 2013

Recursive Square root function in C++

/*
QUESTION:
Write Recursive square root function


CODE:
*/

#include<iostream.h>   
double sqrt( int n,int rep=0)
static double x=1;
if(n<=rep)

 return 0;
else
x=0.5*(x+n/x);
 sqrt(n,++rep);
return x;
 }  
int main()
{
int a;
cout<<"enter the a"<<endl;
cin>>a;
cout<<sqrt(a)<<endl;
}
 

Link LIst In Structures in C++

/*
QUESTION:
1. Write a menu­ driven program for managing the operations of a Store. The program would

allow a user to perform the operations given below on store items stored in a linked list. A store

item has an ID (an integer), a name (up to 50 characters) and quantity of that item in the store

(an integer).

2. Add a new item to the store. Ask the user to specify the position where the new item is added.

An error message should be displayed if the position is invalid. For example, an error should be

displayed if the user enters a negative value or zero for the position, or if the position exceeds

one more than the position of the last element in the list.

3. Sell an item. Prompt the user for the ID of the item and quantity to be sold. Locate that item in

the linked list, verify if you have enough quantity of that available in the store. If enough quantity is

available, sell the item by updating the quantity. If the remaining quantity of that item is zero,

delete that item’s record from the linked list.

4. Delete a specific Item from the store. Prompt the user for the ID of the item to be deleted.

Remove the record of that item from the list free its memory using delete. An error message

should be displayed if there is no item in the store with the given ID.

5. Modify the name of an item. Prompt the user for the ID and the new name of the item to be

renamed. Locate that item in the linked list and update its name. An error message should be

displayed if there is no item in the store with the given ID.

6. Find an item. Prompt the user for the name of the item to be found. Locate that item in the

linked list and display its ID, name and remaining quantity in the store. An error message should

be displayed if there is no item in the store with the given name.

7. Print the ID, name and available quantity of all the items in the store.
 


CODE:

*/


#include <iostream>
#include <windows.h>
using namespace std;
int Counter=0;
///////////////////////////////////////Structure
struct node {
 int id;
 char name[50];
 int Quanty;
 node *next;

};
///////////////////////////////////Taking data from User
node *get_data()
{
 ++Counter;
 node *p = new node;
 cout<<"ENTER ID:  "; cin >> p->id;
 cout<<"ENTER Name:  "; cin >> p->name;
 cout<<"ENTER Quantity:  "; cin >> p->Quanty;
 cout<<"\n\n\n";
 p->next = NULL;

 return p;

}
////////////////////////////////////////////////////////////////Build Linked List
void insert_node (node **ph , node **pt , node *pd)
{
 if(*ph == NULL && *pt== NULL)
 {
  *ph = pd;
  *pt = pd;

 }
 else
 {
  (*pt)->next=pd;
  *pt = pd;
 }
}
////////////////////////////////////////////////////////////////////ISERT at User Desire position
void insertkaar(node **HEAD ,node *newn , int position_no ){   
 node *Front_ptr=*HEAD ,   *Back_ptr=NULL; int Loop=1;
 while (Loop != position_no )
 {
  Back_ptr=Front_ptr;         Front_ptr=Front_ptr->next;    
  Loop++;
 }
 Back_ptr->next=newn ; 
 newn->next=Front_ptr;

}
///////////////////////////////////////According to User Desire Insert New record  at begining of Linked list
void insertion(node **P_H ,node *n)
{
 n->next = *P_H;
 *P_H = n;

}
/////////////////////////////////////According to User Desire Insert New record  at the END of Linked list
void Insert_Tail(node ** Tail , node *Temp)
{
 (*Tail)->next = Temp  ;
 *Tail = Temp ;
}
 //////////////////////////Deleting a memory From List
void  Delete_record(node **HEAD , int position_no )
{
 node *Front_ptr=*HEAD ,   *Back_ptr=NULL; int Loop=1; node * Delt_ptr=NULL;
 while (Loop != position_no )
 {
  Back_ptr=Front_ptr;
  Front_ptr=Front_ptr->next;
  Delt_ptr=Front_ptr;
  Loop++;
 }

 Front_ptr=Front_ptr->next ; 
 Back_ptr->next=Front_ptr;

    delete Delt_ptr;
 Delt_ptr=NULL;
}
 ///////////////Find ID of User desired
void Find_ID(node *HEAD , int Target)
{
 node *p = HEAD;
 while(p != NULL)
 {
  if(p->id == Target)
  {
   cout<<"Info of that Person is follow as\nNAME is:  "<<p->name<<"\nID is:  "<<p->id;
   cout<<"\nRemaining Quantity is:  "<<p->Quanty<<endl<<endl;

  }
  p=p->next;
 }


}
 ///////////////////////Display whole Linked List
void display_data(node *p)
{
 while(p != NULL)
 {
  cout<<"ID  "<<p->id<<endl;
  cout<<"Name    "<<p->name<<endl;
  cout<<"Quantity    "<<p->Quanty<<"\n\n\n";
  p=p->next;
 }

}
 ////////////////////////////MAIN Start
int main()
{
 int menu_no;  int position_no;
 node *head=NULL , *tail=NULL , *temp=NULL;

start:
 cout<<"press 1 for Enter a Data of new item to store\n";
 cout<<"press 2 for Insert a new item in existing linked List\n";
    cout<<"press 3 to delete a specific item from the store\n";
 cout<<"press 4 to find an item\n";
 cout<<"press 5 to see data of items stored\n\n\n";
 cout<<"choose a number from menu and Enter that for further procedure:  ";
 cin>>menu_no;
   switch (menu_no)
 {
 case 1:

  temp = get_data();
  insert_node(&head , &tail , temp);
  break;
 case 2:
  cout<<"\n\nEnter position number wher you want to insert  data:  "; cin>>position_no;
  if (position_no < 0  || position_no == 0 || position_no > Counter + 1 )
  {
   cout<<"You have entered Invalid position number.Plz enter correct Location";
  }

  else
   if( position_no == 1 )
   {
  
    temp = get_data();
    insertion(&head , temp);
   }
   else
    if( position_no < Counter + 1 )
    {
     temp = get_data();
     insertkaar( &head ,temp , position_no  );
   
    }
    else
     if( position_no == Counter + 1 )
    
     {
      temp = get_data();
      Insert_Tail(&tail , temp);
     }
     break;
   
 case 3:

  cout<<"From which Location you want to delete data:   "; cin>> position_no;
  if (position_no < 0  || position_no == 0 || position_no > Counter + 1 )
  {
   cout<<"You have entered Invalid position number.Plz enter correct Location";
  }
  else
   Delete_record( &head , position_no );

  break;
 case 4:
        int Target;
        cout<<"\n\nEnter a ID that u want to find in existing List:   "; cin>> Target;
        Find_ID(head ,  Target);
        break;
       
       
 case 5:
  display_data(head);

  break;



 }

 if (menu_no < 7)
 {
  goto start;

 }
 return 0;
}

Linked List In Classes in C++

/*
QUESTION:
1. Write a menu­ driven program for managing the operations of a Store. The program would

allow a user to perform the operations given below on store items stored in a linked list. A store

item has an ID (an integer), a name (up to 50 characters) and quantity of that item in the store

(an integer).

2. Add a new item to the store. Ask the user to specify the position where the new item is added.

An error message should be displayed if the position is invalid. For example, an error should be

displayed if the user enters a negative value or zero for the position, or if the position exceeds

one more than the position of the last element in the list.

3. Sell an item. Prompt the user for the ID of the item and quantity to be sold. Locate that item in

the linked list, verify if you have enough quantity of that available in the store. If enough quantity is

available, sell the item by updating the quantity. If the remaining quantity of that item is zero,

delete that item’s record from the linked list.

4. Delete a specific Item from the store. Prompt the user for the ID of the item to be deleted.

Remove the record of that item from the list free its memory using delete. An error message

should be displayed if there is no item in the store with the given ID.

5. Modify the name of an item. Prompt the user for the ID and the new name of the item to be

renamed. Locate that item in the linked list and update its name. An error message should be

displayed if there is no item in the store with the given ID.

6. Find an item. Prompt the user for the name of the item to be found. Locate that item in the

linked list and display its ID, name and remaining quantity in the store. An error message should

be displayed if there is no item in the store with the given name.

7. Print the ID, name and available quantity of all the items in the store.
 


CODE:
*/



#include <iostream>
#include <windows.h>
using namespace std;
int Counter=0;
///////////////////////////////////////Structure
class node {
private:
 int id;
 char name[50];
 int Quanty;
 node *next;
public:
///////////////////////////////////Taking data from User
node*  get_data()
{
 ++Counter;
 node *p = new node;
 cout<<"ENTER ID:  "; cin >> p->id;
 cout<<"ENTER Name:  "; cin >> p->name;
 cout<<"ENTER Quantity:  "; cin >> p->Quanty;
 cout<<"\n\n\n";
 p->next = NULL;

 return p;

}
////////////////////////////////////////////////////////////////Build Linked List
void insert_node (node **ph , node **pt , node *pd)
{
 if(*ph == NULL && *pt== NULL)
 {
  *ph = pd;
  *pt = pd;

 }
 else
 {
  (*pt)->next=pd;
  *pt = pd;
 }
}
////////////////////////////////////////////////////////////////////ISERT at User Desire position
void insertkaar(node **HEAD ,node *newn , int position_no ){   
 node *Front_ptr=*HEAD ,   *Back_ptr=NULL; int Loop=1;
 while (Loop != position_no )
 {
  Back_ptr=Front_ptr;         Front_ptr=Front_ptr->next;    
  Loop++;
 }
 Back_ptr->next=newn ; 
 newn->next=Front_ptr;

}
///////////////////////////////////////According to User Desire Insert New record  at begining of Linked list
void insertion(node **P_H ,node *n)
{
 n->next = *P_H;
 *P_H = n;

}
/////////////////////////////////////According to User Desire Insert New record  at the END of Linked list
void Insert_Tail(node ** Tail , node *Temp)
{
 (*Tail)->next = Temp  ;
 *Tail = Temp ;
}
//////////////////////////////////////////////////Deleting a memory From List
void  Delete_record(node **HEAD , int position_no )
{
 node *Front_ptr=*HEAD ,   *Back_ptr=NULL; int Loop=1; node * Delt_ptr=NULL;
 while (Loop != position_no )
 {
  Back_ptr=Front_ptr;
  Front_ptr=Front_ptr->next;
  Delt_ptr=Front_ptr;
  Loop++;
 }

 Front_ptr=Front_ptr->next ; 
 Back_ptr->next=Front_ptr;

    delete Delt_ptr;
 Delt_ptr=NULL;
}
//////////////////////////////////////Find ID of 
void Find_ID(node *HEAD , int Target)
{
 node *p = HEAD;
 while(p != NULL)
 {
  if(p->id == Target)
  {
   cout<<"Info of that Person is follow as\nNAME is:  "<<p->name<<"\nID is:  "<<p->id;
   cout<<"\nRemaining Quantity is:  "<<p->Quanty<<endl<<endl;

  }
  p=p->next;
 }


}
///////////////////////////////////////Display 
void display_data(node *p)
{
 while(p != NULL)
 {
  cout<<"ID  "<<p->id<<endl;
  cout<<"Name    "<<p->name<<endl;
  cout<<"Quantity    "<<p->Quanty<<"\n\n\n";
  p=p->next;
 }

}
};

int main()
{
 int menu_no;  int position_no;
 node *head=NULL , *tail=NULL , *temp=NULL;

start:
 cout<<"press 1 for Enter a Data of new item to store\n";
 cout<<"press 2 for Insert a new item in existing linked List\n";
    cout<<"press 3 to delete a specific item from the store\n";
 cout<<"press 4 to find an item\n";
 cout<<"press 5 to see data of items stored\n\n\n";
 cout<<"choose a number from menu and Enter that for further procedure:  ";
 cin>>menu_no;
  node obj;
 switch (menu_no)
 {
 case 1:

  temp = obj.get_data();
  obj.insert_node(&head , &tail , temp);
  break;
 case 2:
  cout<<"\n\nEnter position number wher you want to insert  data:  "; cin>>position_no;
  if (position_no < 0  || position_no == 0 || position_no > Counter + 1 )
  {
   cout<<"You have entered Invalid position number.Plz enter correct Location";
  }

  else
   if( position_no == 1 )
   {

    temp = obj.get_data();
    obj.insertion(&head , temp);
   }
   else
    if( position_no < Counter + 1 )
    {
     temp = obj.get_data();
     obj.insertkaar( &head ,temp , position_no  );
  
    }
    else
     if( position_no == Counter + 1 )
   
     {
      temp = obj.get_data();
      obj.Insert_Tail(&tail , temp);
     }
     break;
  
 case 3:

  cout<<"From which Location you want to delete data:   "; cin>> position_no;
  if (position_no < 0  || position_no == 0 || position_no > Counter + 1 )
  {
   cout<<"You have entered Invalid position number.Plz enter correct Location";
  }
  else
   obj.Delete_record( &head , position_no );

  break;
 case 4:
        int Target;
        cout<<"\n\nEnter a ID that u want to find in existing List:   "; cin>> Target;
        obj.Find_ID(head ,  Target);
        break;
       
       
 case 5:
  obj.display_data(head);

  break;



 }

 if (menu_no < 7)
 {
  goto start;

 }
 return 0;
}