#include <stdio.h>
#include <stdlib.h>

struct node{
    int data;
    struct node* next;
};

int main() {
    struct node *a, *b, *c;
    a=(struct node*)malloc(sizeof(struct node));
    b=(struct node*)malloc(sizeof(struct node));
    c=(struct node*)malloc(sizeof(struct node));

    a->data=1;
    a->next=b;
    b->data=2;
    b->next=c;
    c->data=3;
    c->next=NULL;

    int sum;

    struct node* tmp = a;
    while(tmp!=NULL){
        sum = sum + tmp->data;
        tmp=tmp->next;
    }
    printf("%d",sum);
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: