Skip to content

Instantly share code, notes, and snippets.

@saifsmailbox98
Created April 21, 2018 01:59
Show Gist options
  • Save saifsmailbox98/e8b35a903b30dcc9c7f89e6bb6ac4d81 to your computer and use it in GitHub Desktop.
Save saifsmailbox98/e8b35a903b30dcc9c7f89e6bb6ac4d81 to your computer and use it in GitHub Desktop.
#include < stdio.h >
struct Node {
int data;
struct Node * next;
};
void display(struct Node * next) {
while (next != NULL) {
printf("%d", next - > data);
next = next - > next;
}
}
void main() {
struct Node * head;
struct Node * second;
clrscr();
head = (struct Node * ) malloc(sizeof(struct Node));
second = (struct Node * ) malloc(sizeof(struct Node));
printf("Enter the data of 1st node.");
scanf("%d", & head - > data);
head - > next = second;
printf("Enter the data of 2nd node.");
scanf("%d", & second - > data);
second - > next = NULL;
display(head);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment