#include <stdio.h> #include <stdlib.h> struct Node{ int data; struct Node *next; }*first=NULL; void create(int A[10], int n){ int i; struct Node *t, *last; first = (struct Node *)malloc(sizeof(struct Node)); first->data=A[0]; first->next=NULL; last=first; for(i=1;i<n;i++){ t=(struct Node*)malloc(sizeof(struct Node)); t->data=A[i]; t->next=NULL; last->next=t; last=t; } } void Display(struct Node *p){ while(p!=NULL){ printf("%d ",p->data); p=p->next; } } int main() { int A[]={3,5,7,10,15}; create(A,5); Display(first); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter