diff --git a/DS assignment 3/Program_to_Create_a_linked_list.c b/DS assignment 3/Program_to_Create_a_linked_list.c index a69bcef..2c3f358 100644 --- a/DS assignment 3/Program_to_Create_a_linked_list.c +++ b/DS assignment 3/Program_to_Create_a_linked_list.c @@ -1,10 +1,6 @@ -//DSA //Write a program to create a linkedList -//Name-Sai Prashant Saxena -//Roll no-02220902719 - #include #include @@ -20,10 +16,10 @@ int main() struct node *head = (struct node *)malloc(sizeof(struct node)); struct node *temp = head; printf("Hello there!!"); - printf("\nWant to create a linked list press Y.....\n\t\t"); + printf("\nWant to create a linked list press 1.....\n\t\t"); char c; scanf("%c", &c); - if (c == 'Y' || c == 'y') + if (c == 1) { printf("Enter the value of head\n "); int value; @@ -40,11 +36,12 @@ int main() } int ch; + addNode: printf("Want to add more values to linked list press 1...\n "); scanf("%d", &ch); if (ch == 1) { - addNode: + printf("Enter the next value\n "); int value; scanf("%d", &value); @@ -62,18 +59,9 @@ int main() printList(head); goto end; } - printf("Want to add more values to linked list press 1...\n "); - scanf("%d", &ch); - if (ch == 1) - { - goto addNode; - } - else - { - printf("Your Linked List..\n"); - printList(head); - } - + + goto addNode; + end: return 0; } @@ -83,7 +71,7 @@ void printList(struct node *head) printf("\n"); while (temp != NULL) { - printf("-->%d Address of node: %d",temp->info,temp); + printf("-->%d ",temp->info); printf("\t Next:%d\n",temp->link); temp = temp->link; }