Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a C code
to reverse a string using a recursive function, without
swapping or using an extra memory.

Answers were Sorted based on User's Feedback



write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / valli

void reverse(char s[],int len)
{
putchar(s[len]);
len--;
if(len>=0)
reverse(s,len);

return;
}

Is This Answer Correct ?    49 Yes 33 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / noone

/* this one is a copy of a earlier one posted i just made a
small adjustment */
void reverse(char *str)
{
if(*str)
{
reverse(str+1);
putchar(*str);
}
}

Is This Answer Correct ?    18 Yes 5 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / sampath

void reverse(*str)
{
if(*str)
{
reverse(str+1);
putchar(*str);
}
}

Is This Answer Correct ?    58 Yes 51 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / asdf

void reverse(*str)
{
if(*str){
reverse(++str);
str--;
printf("%c",*str);
}
}

Is This Answer Correct ?    16 Yes 9 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / mohan

#include <stdio.h>
#include <string.h>

void reverse(char **s, int start, int last)
{
char tmp;
if (start >= last)
return;
char *s2 = *s;
tmp = s2[start];
s2[start] = s2[last];
s2[last] = tmp;
reverse(s, start + 1, last - 1);
}
int main()
{
char *s = strdup("Hello World");
printf("%s\n", s);
reverse(&s, 0, strlen(s) - 1);
printf("%s\n", s);
}

Is This Answer Correct ?    5 Yes 1 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / billy

string reverse with out recursion


void rev( char *p )
{

char tmp;
int len =strlen(p)-1;
for( int i=0 ; i <= len/2 ; i++ )
{


tmp = p[i] ;
p[i] = p[len - i ] ;
p[len - i ] = tmp ;
}


printf("%s",p);


}

Is This Answer Correct ?    1 Yes 0 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / jainendra

#include<stdio.h>
#define MAX 100
char* getReverse(char[]);

int main(){

char str[MAX],*rev;

printf("Enter any string: ");
scanf("%s",str);

rev = getReverse(str);

printf("Reversed string is: %s",rev);
return 0;
}

char* getReverse(char str[]){

static int i=0;
static char rev[MAX];

if(*str){
getReverse(str+1);
rev[i++] = *str;
}

return rev;
}

Is This Answer Correct ?    1 Yes 0 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / sanny

#include<stdio.h>
#include<conio.h>
main()
{
int num, rem=0;
printf("\n Enter the number ");
scanf("%d", &num);
while(num>0)
{
rem = (rem * 10) + (num % 10);
num = num / 10;
}
printf("\n Reverse of the number is %d", rem);
getch();
}

Is This Answer Correct ?    10 Yes 15 No

write a C code to reverse a string using a recursive function, without swapping or using an extr..

Answer / piyush kumar

char gacstring="piyush";
int giindex=0;
voidfnreverse();
void main()
while(gacstring[giindex]!='\0'){
giindex++;
voidfnreverse();
}
if(giindex>0)
giindex--;
printf("%c",chargacstring);
return 0;
}

Is This Answer Correct ?    4 Yes 14 No

Post New Answer

More C Interview Questions

what is the different between data structure and data type?

1 Answers   Ignou,


How to draw the flowchart for structure programs?

0 Answers  


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

0 Answers  


Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80

0 Answers  


Explain About fork()?

0 Answers   TISL,


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

0 Answers  


int a[3][5]={ {1,2,3,4,5],{2,3,4,5,6},{10,11,12,13,14}}; int *p=&a; printf(“%d”,*(*(x+1)+3));

2 Answers   Wipro,


Is sizeof a keyword in c?

0 Answers  


What is a segmentation fault?

2 Answers  


write a c/c++ programthat connects to a MYSQL server and checks if the INNoDB plug in is installed on it.If so your program should print the total number of disk writes by MYSQL.

0 Answers   BirlaSoft,


What is scanf_s in c?

0 Answers  


Are the variables argc and argv are local to main?

0 Answers   TISL,


Categories