Monday, April 12, 2021

20.53. Write a program that create a link list to store some integer numbers.

#include<stdio.h>
#include<conio.h>
include<stdlib.h>
struct node
{
int info;
struct node *next;
};
struct node *makenode (int 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, rum;
printf("How many node: "); scanf ("d", &n, ;
For (i=1; i<=n; i++)
{
scanf("%d",&num);
list->next namenode (num);
list=list->next;
}
}
void printlist (struct node *list)
{
printf("\nList contains: \n");
while (list->next!=NULL)
{
printf("%5d",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