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

Engineering Safety
For safety, speed and fuel efficiency, when designing recreation and transportation vehicles, engineers take into account all forces acting on the object. Engineers consider drag forces when they design...

Lazy initialization Vs Eager initialization
Memory and resource utilization plays crucial role in current enterprise era developers always need to take care of resource creation, utilization and it's cleanness on correct time to make application...
M

Test On Thermo
All perfect gases change in volume by 1/273th of its original volume at 0°C for every 1°C change in temperature, when the pressure remains constant. This statement is called (A) Boyle's law (B)...

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...

Types of Survey
Surveying Surveying is defined as a measurement of any two relative positions on the Earth or below the Earth or above the Earth. Types of Surveying On the basis of whether the the curvature of the...
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