#include
using namespace std;
class node{
public:
int data;
node* next;
node(int d){
data = d;
next = NULL;
}
};
void insertAtHead(node*&head,int data){
if(head==NULL){
head = new node(data);
return;
}
node*n = new node(data);
n->next = head;
head = n;
}
void print(nodehead){
while(head!=NULL){
cout<data<<"->";
head = head->next;
}
cout<<endl;
}
void reverseLl(nodehead) // this is the fuction of reversing linked list
{
while(head!=NULL)
{
head->next->next=head->next;
head=head->next;
}
head=head->next;
}
int main(){
node*head = NULL;
insertAtHead(head,7);
insertAtHead(head,6);
insertAtHead(head,5);
insertAtHead(head,4);
print(head);
reverseLl(head);
print(head);
}
