Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:24:51+00:00 2026-05-26T02:24:51+00:00

Here is simple linked list code: #include <iostream> using namespace std; class link {

  • 0

Here is simple linked list code:

#include <iostream>
using namespace std;
class link
{
    public:
    int data;
    double ddata;
    link *next;
    link(int id,double dd){
        data=id;
        ddata=dd;
    }

    void diplay(){
        cout<<data<<" ";
        cout<<data<<" ";

    }
};

class linkedlist{
    private :
        link *first;
    public:
        linkedlist(){
            first=NULL;
        }

        bool empthy(){
            return (first==NULL);
        }

        void insertfirst(int id,double dd){
            link *newlink=new link(id,dd);
            newlink->next=first;
            first=newlink;
        }

        link* deletefirst(){
            link *temp=first;
            first=first->next;
            return temp;
        }

        void display(){
            cout<<" (list ( first -> last ) )   ";
            link *current=first;
            while(current!=NULL){
                current->diplay();
                current=current->next;
            }
            cout<<endl;
        }
};

int main(){
    linkedlist *ll=new linkedlist();
    ll->insertfirst(22,2.99);
    ll->insertfirst(34,3.99);
    ll->insertfirst(50,2.34);
    ll->insertfirst(88,1.23);
    ll->display();
    return 0;
}

But it is giving me unexpected results. It prints 88 88 50 50 34 34 22 22 instead of (88,1.23) (50,2.34) (34,3.99) (22,2.99)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:24:52+00:00Added an answer on May 26, 2026 at 2:24 am
    void diplay(){
    
                 cout<<data<<" ";
                 cout<<ddata<<" ";
    
                 }
    

    Replace the display function with this code. (Instead of printing data and ddata you printed data twice)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple C code for constructing a Singly Linked list as
I am trying to implement a linked list for a data structures class and
I'm writing a simple linear linked list implementation in PHP. This is basically just
I am trying to implement a simple singly linked list of integers which are
i'm trying to create a simple single linked list in python. (i know there
Anyone know where I can obtain generic sample code for using an adjacency list
so I'm creating a linked list counter for fun, here's my program. WHAT I
I'm currently implementing a copy constructor for a Linked List class. When I create
I'm probably missing something simple here, but I can't find the answer elsewhere. I
I am probably overlooking something really simple here but I am trying to redirect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.