Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct node
- {
- int a;
- struct node *next;
- };
- struct node* second(struct node*temp)
- {
- struct node*p;
- p=temp;
- while(temp->next!=NULL)
- {
- p=temp;
- temp=temp->next;
- }
- cout<<p->a<<endl;
- };
- struct node *head=NULL,*temp;
- int main()
- {
- struct node *n1,*n2;
- n1=(struct node*) malloc (sizeof(struct node));
- cout<<"give information for n1"<<endl;
- cin>>n1->a;
- n1->next=NULL;
- head=n1;
- cout<<"give information for n2"<<endl;
- cin>>n2->a;
- n2->next=NULL;
- n1->next=n2;
- temp=head;
- second(temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement