#include<stdio.h>

#include<conio.h>

#include<malloc.h>

struct list{

int roll_no; /* Storing roll number of a node */

// char name[N]; /* Storing name of node */

float marks; /* Storing marks of a node */

struct list *next; /* Storing next address */

};

/***** Redefining struct list as node *****/

typedef struct list node;

node* swap(node *current)

{

int rno; /* Roll number for swaping node*/

int t; /* Total number of nodes */

node *temp; /* Temporary copy of current */

node *tmp; /* Temporary variable */

t=number(current);

if(t<=1)

{

printf("\nYou cannot swap the only node\n");

return(current);

}

printf("\nEnter roll number whose node you want to swap with the next\n");

scanf("%d",&rno);

temp=current;

if(current->roll_no==rno)

{

tmp=current->next;

current->next=current->next->next;

tmp->next=current;

current=tmp;

return(current);

}

else

{

while(temp->next->next!=NULL)

{

if(temp->next->roll_no==rno)

{

tmp=temp->next->next;

temp->next->next=temp->next->next->next;

tmp->next=temp->next;

temp->next=tmp;

break;

}

temp=temp->next;

}

return(current);

}

}

int main()

{

head=swap(head); // head is the first node of the linked list

getch();

}