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

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

int main(){
    struct node *a=NULL;
    struct node *b=NULL;
    struct node *c=NULL;
    
    a=(struct node*)malloc(sizeof(struct node));
    b=(struct node*)malloc(sizeof(struct node));
    c=(struct node*)malloc(sizeof(struct node));
    
    a->data=5;
    a->next=b;
    
    b->data=6;
    b->next=c;
    
    c->data=7;
    c->next=NULL;
    
    struct node *current = a;
    struct node *prev = NULL;
    struct node *next = NULL;
    
    while(current!=NULL){
        next=current->next;
        current->next = prev;
        prev = current;
        current = next;
    }
    a=prev;
    
    struct node *tmp = a;
    while(tmp!=NULL){
        printf("%d ",tmp->data);
        tmp=tmp->next;
    }
}

Embed on website

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