Best C programming code for different functions of Linked List (October,2020)

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

typedef struct linked
{
    int val;
    struct linked *next;
}lnk;

lnk *create(lnk*,int);
lnk *insertbefore(lnk*,int);
void insertafter(lnk*,int);
lnk *del(lnk*,int);
void disp(lnk*);

void main()
{
    lnk *h=NULL;
    int v,ch;

    while(1)
    {
printf("\n====================================");
 printf("\n1)Create\n2)Insert Before\n3)Insert After\n4)Delete\n5)Display\n6)Exit");
printf("\n====================================");
 printf("\n\nEnter your choice:");
 scanf("%d",&ch);
 switch(ch)
 {
     case 1: printf("\nEnter the value you want to enter:");
      scanf("%d",&v);
      h=create(h,v);
      break;
     case 2: printf("\nEnter the value before which you want to Insert:");
      scanf("%d", &v);
      h=insertbefore(h,v);
      break;
     case 3: printf("\nEnter the value after which you want to Insert:");
      scanf("%d",&v);
      insertafter(h,v);
      break;
     case 4: printf("\nEnter the value which you want to delete:");
      scanf("%d",&v);
      h=del(h,v);
      break;
     case 5: printf("\nThe values in the list are:");
      disp(h);
      break;
     case 6: exit(0);
     default: printf("\n Not a proper choice,Sir");
 }
    }

}

//create the linked list

lnk *create(lnk *h,int v)
{
    lnk *temp,*ptr;
    temp=(lnk*)malloc(sizeof(lnk));
    temp->val=v;
    temp->next=NULL;
    if(h==NULL)
    {
 h=temp;
    }
    else
    {
 ptr=h;
 while(ptr->next!=NULL)
 {
     ptr=ptr->next;
     ptr->next=temp;
 }
    }
    return h;
}

//insert a node before a particular node

lnk *insertbefore(lnk *h,int v)
{
    lnk *ptr,*pre,*temp;
    int p;
    printf("\nEnter the value of the inserting node:");
    scanf("%d",&p);
    temp=(lnk*)malloc(sizeof(lnk));
    temp->val=p;
    temp->next=NULL;
    if(h->val==v)
    {
 temp->next=h;
 h=temp;
    }
    else
    {
 ptr=h;
 while(ptr->val!=v && ptr!=NULL)
 {
     pre=ptr;
     ptr=ptr->next;
 }
 temp->next=pre->next;
 pre->next=temp;
    }
    return h;
}

//insert a node after a particular node

void insertafter(lnk *h,int v)
{
    lnk *ptr,*temp;
    int p;
    ptr=h;
    while(ptr->val!=v && ptr!=NULL)
    {
     ptr=ptr->next;
    }
    printf("\nEnter the value of the inserting node:");
    scanf("%d",&p);
    temp=(lnk*)malloc(sizeof(lnk));
    temp->next=NULL;
    temp->val=p;
    if(ptr!=NULL)printf("\n====================================");
    {
 temp->next=ptr->next;
 ptr->next=temp;
    }
    else
 printf("\nvalue not found");
}

//delete a particular node

lnk *del(lnk *h,int v)
{
    lnk *pre,*ptr;
    ptr=h;
    if(h->val!=v)
    {
 while(ptr->val!=v && ptr!=NULL)
 {
     pre=ptr;
     ptr=ptr->next;
 }
 if(ptr!=NULL)
 {
     pre->next=ptr->next;
 }
 else
 {
     printf("\nvalue not found");
 }
    }
    else
    {
 h=h->next;
    }
    return h;
}

//display the linked list

void disp(lnk *h)
{
    lnk *ptr;
    ptr=h;
    while(ptr!=NULL)
    {
 printf("%d->",ptr->val);
 ptr=ptr->next;

    }
}

This Post Has 146 Comments

  1. Rosalyn

    I’m not sure exactly why but this web site is loading extremely slow for me.
    Is anyone else having this issue or is it a problem on my end?

    I’ll check back later on and see if the problem still exists.

  2. kebe.top

    Thanks for sharing such a pleasant idea, article is fastidious, thats why i have read it fully

    My blog: ex88 (kebe.top)

  3. Hello There. I found your weblog the usage of msn. That
    is an extremely smartly written article. I’ll be sure to bookmark it and come back
    to learn more of your helpful info. Thank you for the post.
    I’ll certainly return.

    Also visit my web-site: cara masuk id test mega888

  4. mega888apk

    Hi, for all time i used to check webpage posts here early in the morning, because i like
    to learn more and more.

    Visit my webpage: mega888apk

  5. Scr888 Ios

    Howdy! This article couldn’t be written much better! Looking through this article reminds
    me of my previous roommate! He constantly kept preaching about this.
    I will forward this information to him. Pretty sure
    he’ll have a very good read. Many thanks for sharing!

    My web page; Scr888 Ios

  6. Fantastic beat ! I would like to apprentice while you
    amend your website, how can i subscribe for a blog
    site? The account aided me a acceptable deal. I had been tiny bit acquainted of this
    your broadcast provided bright clear concept

  7. 918kaya

    It’s going to be end of mine day, however before finish I am
    reading this enormous paragraph to improve my knowledge.

    Also visit my page – 918kaya

  8. kebe.top

    I just couldn’t depart your web site before
    suggesting that I really loved the usual info an individual provide to your
    visitors? Is going to be back continuously to check out new posts.

    Feel free to surf to my web blog kebe.top

  9. list game xe88

    Wow, superb blog structure! How long have you been running a blog for?
    you make running a blog glance easy. The overall look of your website is wonderful, as
    smartly as the content!

    My webpage: list game xe88

  10. mega888

    What i do not realize is in truth how you’re no longer really a lot more neatly-favored than you may be right
    now. You’re very intelligent. You realize thus significantly on the subject of
    this matter, made me personally imagine it from
    so many varied angles. Its like women and men don’t seem to be involved until it’s something to do with Woman gaga!

    Your personal stuffs outstanding. At all times maintain it up!

    My page – mega888

  11. mega88 test id

    Hi to all, as I am really keen of reading this web site’s post to be updated regularly.
    It contains pleasant data.

    My website :: mega88 test id

  12. I enjoy, lead to I discovered just what I used to be
    taking a look for. You’ve ended my four day lengthy hunt!
    God Bless you man. Have a great day. Bye

    Feel free to visit my web page – game online mega888

  13. 918kaya slot

    Can I simply just say what a comfort to uncover somebody who truly knows what they are
    talking about on the web. You certainly know how to bring
    an issue to light and make it important. More and more people have to
    look at this and understand this side of your story.
    I can’t believe you aren’t more popular because you surely
    possess the gift.

    Look at my web-site … 918kaya slot

  14. mega888 test id

    Right here is the perfect site for everyone who would like to understand this topic.
    You understand a whole lot its almost hard to argue with you (not that
    I personally will need to…HaHa). You definitely put a
    brand new spin on a subject that’s been discussed for years.

    Excellent stuff, just wonderful!

    Also visit my webpage mega888 test id

  15. download 918kaya

    Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something.
    I think that you could do with some pics to drive the message home a bit, but other than that, this is excellent blog.
    A great read. I’ll definitely be back.

    My webpage: download 918kaya

  16. Link exchange is nothing else however it
    is only placing the other person’s webpage link on your
    page at proper place and other person will also do same in support
    of you.

  17. Hi there! I just wanted to ask if you ever have any issues with hackers?
    My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no backup.
    Do you have any methods to stop hackers?

  18. It’s the best time to make some plans for the future and it is time to be happy.

    I’ve read this post and if I could I wish to suggest you some
    interesting things or tips. Perhaps you could write next articles referring
    to this article. I desire to read even more things about it!

    Also visit my website … https://www.qiurom.com/

  19. Judy

    Hello there! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly?
    My blog looks weird when viewing from my iphone.
    I’m trying to find a template or plugin that might be able
    to fix this issue. If you have any suggestions, please
    share. Appreciate it!

    my web site: 918kaya online (Judy)

  20. Rosalind

    It’s remarkable to visit this site and reading the views of all colleagues regarding this post, while I am also keen of getting knowledge.

    Here is my webpage :: xe88 online (Rosalind)

  21. wiki.sennadar.com

    It’s a pity you don’t have a donate button! I’d
    definitely donate to this fantastic blog!
    I guess for now i’ll settle for bookmarking and adding your RSS
    feed to my Google account. I look forward to new updates and will
    talk about this blog with my Facebook group.
    Talk soon!

  22. demo mega888

    Hi there, I discovered your website by means of Google whilst looking for a related matter, your website got here up, it seems good.

    I have bookmarked it in my google bookmarks.

    Hello there, simply was alert to your blog through Google,
    and located that it’s really informative. I am gonna
    be careful for brussels. I will appreciate for those who continue this in future.
    Many people will likely be benefited out of your writing.
    Cheers!

    Visit my website; demo mega888

  23. It is perfect time to make some plans for the future and it’s time to be happy.

    I have read this post and if I could I want to suggest you some interesting things or tips.
    Maybe you could write next articles referring to this article.

    I desire to read more things about it!

  24. tip menang xe88

    I have read so many articles or reviews on the topic of the blogger lovers but this piece
    of writing is in fact a good piece of writing, keep it up.

    My webpage; tip menang xe88

  25. Nydia

    Hi there! Someone in my Myspace group shared this site with
    us so I came to take a look. I’m definitely enjoying the information. I’m bookmarking
    and will be tweeting this to my followers! Outstanding blog and fantastic design.

    Also visit my blog … mega888 ios (Nydia)

  26. ecosystem.fi

    Hi there, of course this article is in fact fastidious and I have learned lot of things from it
    concerning blogging. thanks.

    My webpage pussy888 apk download – ecosystem.fi,

  27. It’s a pity you don’t have a donate button! I’d certainly donate to this superb blog!
    I suppose for now i’ll settle for book-marking and adding your
    RSS feed to my Google account. I look forward to brand
    new updates and will share this site with my Facebook group.
    Chat soon!

    Stop by my web site :: cara main game xe88

  28. xe888apk

    Fantastic goods from you, man. I’ve remember your stuff previous
    to and you are just too wonderful. I really like what you’ve bought
    here, really like what you are stating and
    the way wherein you assert it. You’re making it
    enjoyable and you still take care of to keep it smart.
    I can’t wait to read far more from you. This is actually a tremendous site.

    my web blog :: xe888apk

  29. FD

    Hi there I am so delighted I found your blog, I really found you by accident,
    while I was researching on Digg for something else, Nonetheless I am here now
    and would just like to say kudos for a tremendous post and a all
    round enjoyable blog (I also love the theme/design), I don’t
    have time to read it all at the moment but I have book-marked it and also added your RSS feeds,
    so when I have time I will be back to read a lot more, Please do keep up
    the fantastic b.

  30. wonderful publish, very informative. I wonder why the opposite experts of this
    sector do not notice this. You must proceed your writing.
    I’m confident, you have a huge readers’ base already!

    My blog post: pusy888; https://blacklapedia.com/,

  31. freeholmes.com

    Greetings! Very helpful advice within this article!
    It is the little changes that produce the largest changes.
    Thanks a lot for sharing!

  32. Dick

    I needed to thank you for this excellent read!! I definitely enjoyed every little bit of it.
    I’ve got you bookmarked to look at new stuff you post…

    Feel free to visit my blog post; mega888 download (Dick)

  33. mega888 malaysia

    Because the admin of this web site is working, no question very soon it will be well-known, due to its feature contents.

    Review my homepage: mega888 malaysia

  34. www.brq520.com

    Wonderful beat ! I would like to apprentice at the
    same time as you amend your website, how can i subscribe for a blog site?
    The account aided me a acceptable deal. I had been a little bit
    familiar of this your broadcast offered vibrant transparent
    idea

    Here is my page … http://www.brq520.com

  35. maps.google.com

    I was extremely pleased to discover this web site.
    I need to to thank you for ones time for this wonderful read!!
    I definitely liked every part of it and i also have you bookmarked
    to check out new things on your blog.

  36. site here

    Excellent, what a webpage it is! This website provides valuable data to us, keep it up.

  37. pussy888 android

    This is really interesting, You’re a very skilled blogger.
    I’ve joined your feed and look forward to seeking more
    of your excellent post. Also, I’ve shared your site in my social networks!

    Feel free to surf to my homepage pussy888 android

  38. like this

    Hi, after reading this amazing piece of writing i am as well
    delighted to share my experience here with
    colleagues.

  39. xe88 online

    Hi there, of course this article is in fact nice and I have learned lot of things from it regarding blogging.

    thanks.

    My web page; xe88 online

  40. First of all I would like to say terrific blog! I had a quick question in which I’d like to ask if you do not mind.

    I was curious to find out how you center yourself and clear your
    thoughts prior to writing. I have had a hard time clearing my thoughts
    in getting my thoughts out. I do enjoy writing
    but it just seems like the first 10 to 15 minutes are generally lost simply
    just trying to figure out how to begin. Any ideas or tips?

    Appreciate it!

  41. t.me

    It’s a shame you don’t have a donate button! I’d definitely donate to this
    outstanding blog! I suppose for now i’ll settle for bookmarking and adding your RSS
    feed to my Google account. I look forward to brand new updates and will share
    this blog with my Facebook group. Talk soon!

  42. geegram.net

    As soon as I found this site I went on reddit to share some of the love with them.

    Have a look at my web-site geegram.net

  43. audiodat.ru

    My brother recommended I might like this website. He was totally right.
    This post actually made my day. You cann’t imagine simply how much time I had
    spent for this info! Thanks!

  44. mega888

    You can certainly see your skills in the work
    you write. The sector hopes for more passionate writers such as you
    who are not afraid to say how they believe. At all times follow your heart.

    my page: mega888

  45. get more info

    With reside scores you can effortlessly hold on track on your favorite teams, leagues and sports with any of your devices.

  46. Rosario

    I’d like to thank you for the efforts you have put in writing this blog.
    I’m hoping to view the same high-grade blog posts by you later
    on as well. In truth, your creative writing abilities has encouraged me to get my own blog now ;
    )

  47. Jeanna

    I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly.
    I’m quite sure I will learn many new stuff right
    here! Good luck for the next!

  48. Charlotte

    It’s remarkable to pay a visit this web page and reading the views of all mates regarding this post, while
    I am also zealous of getting knowledge.

  49. Howdy! I simply want to give you a big thumbs up for
    your great info you have right here on this post. I’ll
    be coming back to your blog for more soon.

  50. texaspokercc

    Hello There. I found your blog using msn. This is a very well written article.
    I will be sure to bookmark it and come back to read more
    of your useful info. Thanks for the post. I’ll definitely return.

  51. Please let me know if you’re looking for a article author
    for your blog. You have some really great posts and
    I think I would be a good asset. If you ever want to take some of the
    load off, I’d love to write some content for your blog in exchange for
    a link back to mine. Please shoot me an e-mail if interested.
    Kudos!

    1. Kumar Gourab

      thanks a lot … I am sorry presently I am not in any condition to hire some one as author.. but obviously for the future .. if you need any type of wordpress website please feel free to contact and please subscribe for more such post… contact for further query [email protected]

  52. w88

    Excellent post. Keep writing such kind of info on your blog.
    Im really impressed by your blog.
    Hey there, You’ve done an excellent job. I will certainly
    digg it and in my view suggest to my friends. I’m confident they’ll be benefited from this web site.

Leave a Reply to list game xe88 Cancel reply