UrbanPro
true

Take BTech Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Data Structure with C

S
Sudipta Saha
19/11/2016 0 0

#include

#include

#include

#include

struct node

{

int data;

struct node *next;

}*start=NULL;

void create();

void display();

void search();

void main()

{

int ch;

clrscr();

while(1)

{

printf("choose... 1. create node \n 2.display \n 3. search \n 4. exit\n");

      scanf("%d",&ch);

switch(ch)

{

case 1:

create();

break;

case 2:

display();

break;

case 3:

search();

break;

case 4:

exit(0);

break;

default:

printf("invalid choice \n");

}

}

}

void create()

{

 

  struct node *p,*q;

p=(struct node *)malloc(sizeof(struct node));

 int  a;

 printf("press -1 to exit \n");

 scanf("%d",&a);

 while (a!=-1)

 {

  printf("\n Enter the data : ");

  scanf("%d",&p->data);

  p->next=NULL;

if(start==NULL)

  {

  start=p;

  return;

  }

    q=start;

    while(q->next!=NULL)

q=q->next;

 q->next=p;

}

  }

void display()

{

struct node *q;

 printf("The Linked List : n");

 q=start;

 while(q!=NULL)

   {

   printf("%d--->",q->data);

   q=q->next;

   }

}

 

 void search()

 {

   int item=0,f=0;

 struct node *q;

  printf (" enter the data to searche \n");

  scanf("%d",&item);

  q=start;

  while(q!=NULL)

  {

      if(q->data==item)

     {

      f=1;

      break;

      }

  q=q->next;

   }

   if (f==1)

       printf(" search successful \n");

       else

       printf(" searching not sucessful \n");

  }

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

smart work with patience creates victory
In a village named ramapuram aa unemployee gopi lives. He is in search of job, roaming without food from a week. He decided to sell the wooden sticks by chopping the tree, he started chopping the trunk...

Computer Fundamentals
Computer:Computer can be defined on an electronic device that accept data, process then at a high speed according to a set of instructions provide to it and produces the desired output. So computer is...

Difference Of Inheritance In C++ And Java
In Java , multiple inheritance is not applicable directly but we can implement the concept by using the interfaces. In c++ and Java, the common types of inheritances are: Single Multi level Hybrid Hierarchical

Engineering Mechanics Preparation
1.Engineering Mechanics subject becomes easy if Fundamental cocepts are learnt correctly. 2.Take time to learn basics. Then any problem can be solved easily. 3.Practicing number of problems gives us...

How to Study and Learn Better: Tips to Students!
Find out where, when and how you learn best: By taking notes? Reading one book at a time? Through all-out effort? Study groups? Organise your time and the place to study according to that. Take breaks. Check...
X

Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more