Linked List

#include <stdio.h>
#include <stdlib.h>

struct node
{
int x;
struct node*next;
};

int main()
{
struct node *root;
struct node *conductor;
int flag = 0;
root = (struct node*)malloc(sizeof(struct node));
root->next=0;
do
{
printf(“Insert Number [1 – 100] :”);
scanf(“%d”,&root->x);fflush(stdin);
}
while(root->x<0||root->x>100);
flag++;
while(flag<=10)
{
system(“cls”);
conductor=root;
printf(“%d”,conductor->x);
while(conductor->next!=0)
{
conductor=conductor->next;
printf(“->%d”,conductor->x);
}
if(flag==10)
{
break;
}
conductor->next=(struct node*)malloc(sizeof(struct node));
conductor=conductor->next;
conductor->next=0;
printf(“\n”);
do
{
printf(“Insert Number [1 – 100] :”);
scanf(“%d”,&conductor->x);fflush(stdin);
}while(conductor->x<0||conductor->x>100);
flag++;
}
getchar();
return 0;
}

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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