[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Linked List

Home > Programs > Linked List

95 / 16

Write a program to reverse the string using linked list

Answer:

#include "stdio.h"
#include "string.h"                        
#include "malloc.h"
#include
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;
 coutlink=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;
  }
 coutlink=NULL;
  }
  else
  {
   cout

Asked In :: PEOL

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: