Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

Program Discussion :: Linked List
Home > Programs > Linked List

95. Write a program to reverse the string using linked list

Answer:

#include "stdio.h"
#include "string.h"                        
#include "malloc.h"
#include<iostream>
using namespace std;
typedef struct Rev{
 char a;
 struct Rev *link;
}Rev;
int main(){
 Rev *head=NULL,*temp=NULL,*temp1=NULL,*temp2=NULL;
 char b[20];
 int i,j=0,len;
 cout<<"Enter a String: ";
 gets(b);
 len=strlen(b);
 for(i=0;i
  if(head==NULL){
   head=(Rev *)malloc(sizeof(Rev));
   head->a=b[i];
   head->link=NULL;
  }
  else
  {
   temp=head;
   while(temp->link != NULL){
    temp=temp->link;
   }
   temp->link=(Rev *)malloc(sizeof(Rev));
   temp->link->link=NULL;
   temp->link->a=b[i];
  }

 }
 for(i=0;i
  temp1=head;
  temp2=temp1->link;
  if(temp2 != NULL){
  while(temp2->link != NULL){
   temp2=temp2->link;
   temp1=temp1->link;
  }
 cout<<temp2->a;
  temp1->link=NULL;
  }
  else
  {
   cout<<temp1->a;
  }
 }
 return 0;
}

Post Your Answer Here:

Name *
Email

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: