#include<conio.h>
include<stdlib.h>
struct node
{
long info;
struct node *next;
};
struct node *makenode (long n)
{
struct node *t;
t=(struct node *) malloc(sizeof (struct node));
t->info=n;
t->next=NULL;
return t;
}
void makelist (struct node *list)
{
int i, n;
long num;
printf("How many node: ");
printf("How many node: ");
scanf ("%d", &n, ;
For (i=1; i<=n; i++)
{
scanf("%ld",&num);
list->next namenode (num);
list=list->next;
}
}
void printlist (struct node *list)
{
printf("\nList contains: \n");
while (list->next!=NULL)
{
printf("%ld",list->next->info);
list=list->next;
}
}
void main()
{
struct node *start;
start=(struct node *)malloc(sizeof (struct node));,
clrscr();
make list (start);
printlist (start);
getch ();
}
For (i=1; i<=n; i++)
{
scanf("%ld",&num);
list->next namenode (num);
list=list->next;
}
}
void printlist (struct node *list)
{
printf("\nList contains: \n");
while (list->next!=NULL)
{
printf("%ld",list->next->info);
list=list->next;
}
}
void main()
{
struct node *start;
start=(struct node *)malloc(sizeof (struct node));,
clrscr();
make list (start);
printlist (start);
getch ();
}
No comments:
Post a Comment