0% found this document useful (0 votes)
20 views2 pages

Linked List

The document shows code for creating a linked list data structure in C. It includes functions to insert nodes into the list and print the list. The main function prompts the user for input and adds roll numbers, ages, and scores to the linked list by calling the insert function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Linked List

The document shows code for creating a linked list data structure in C. It includes functions to insert nodes into the list and print the list. The main function prompts the user for input and adds roll numbers, ages, and scores to the linked list by calling the insert function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdlib.

h>
#include<stdio.h>
struct Node{
int data;
struct Node* next;
};
struct Node* head;
void Insert(int r);
{
Node* temp = (Node*)malloc(sizeof(struct Node));
temp->.data = r;
temp->next = NULL;
if(head != NULL) temp->next =head;
head = temp;
}
void Print()
{
struct Node* temp = head;
printf("List is: ");
while(temp !=NULL)
{
printf("%d" ,temp->data);
temp= temp->next;
}
printf("\n");
}
int main() {
head = NULL;
int n,r,a,i;
printf("Roll Number:\n");
scanf("%d",&n);
for(i=0;i<r;i++){
printf("Enter the roll number \r");
scanf("%d",&r);
Insert(r);
Print();
printf("Enter the Age \a");
scanf("%d",&a);
Insert(a);
Print();
printf("Enter the CET Score \n");
scanf("%d",&n);
Insert(n);
Print();
}
}

You might also like