I'm practicing on linked list program. I'm taking example of player's
My program is supposed to list player's name with scores.
Player name :---------- Score
Tendulakar ------------ 99
Ganguly -------------- 86
Dravid --------------- 94
I understand basic program for linked list
I have created only three nodes. I can create eleven node's
any help How to make proper program ?
My program is supposed to list player's name with scores.
Player name :---------- Score
Tendulakar ------------ 99
Ganguly -------------- 86
Dravid --------------- 94
I understand basic program for linked list
I have created only three nodes. I can create eleven node's
any help How to make proper program ?
Code:
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int data;
struct Node *next;
};
int main()
{
struct Node* head = NULL;
struct Node* second = NULL;
struct Node* third = NULL;
struct Node *temp = NULL;
head = (struct Node*)malloc(sizeof(struct Node));
second = (struct Node*)malloc(sizeof(struct Node));
third = (struct Node*)malloc(sizeof(struct Node));
head->data = 1; //assign data in first node
head->next = second; // Link first node with second
second->data = 2; //assign data to second node
second->next = third;
third->data = 3; //assign data to third node
third->next = NULL;
temp = head;
while (temp != NULL)
{
printf(" %d ", temp->data);
temp = temp->next;
}
return 0;
}
Last edited: