#include <iostream> typedef struct LNode { int data; struct LNode *next; } LNode; void createList(LNode *&C, int arr[], int n) { LNode *s; int i; C = (LNode *) malloc(sizeof(LNode)); C->next = NULL; for (i = 0; i < n; ++i) { s = (LNode *) malloc(sizeof(LNode)); s->data = arr[i]; s->next = C->next; C->next = s; } }; int main() { int arr[] = {1, 2, 5, 1, 8, 34, 5, 4}; int n = 8; LNode *c; createList(c, arr, n); return 0; }