EmbLogic's Blog

create linklist and display the data

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2014.03.23.22.24.26;    author root;    state Exp;
branches;
next    ;

desc
@create linklist .
@

1.1
log
@Initial revision
@
text
@#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
int roll;
char name[20];
struct node *next;
};
void creat_node(struct node * temp)
{
struct node *start;
temp->next=malloc(sizeof(struct node));
temp=temp->next;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
temp->next=NULL;

}
void display_node(struct node *temp)
{
while(temp!=NULL)
{
printf(“roll is %d\n”,temp->roll);
printf(“name is %s\n”,temp->name);
temp=temp->next;
}
}
int main()
{
int i,n;

struct node *start,*temp;
start=malloc(sizeof(struct node));
temp=start;
printf(“\nentrer the roll”);
scanf(“%d”,&temp->roll);
printf(“enter the name \n”);
scanf(“%s”,temp->name);
printf(“enter the number of no. of node\n”);
scanf(“%d”,&n);
temp->next=NULL;
creat_node(temp);

for(i=0;i<n;i++)
{
creat_node(temp);
temp=temp->next;
}

display_node(start);
{
display_node(start);
}

}
@

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>