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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7413


What is the difference between single charater constant and string constant?

625


Linked lists -- can you tell me how to check whether a linked list is circular?

648


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

925


What does %c mean in c?

656






Explain heap and queue.

591


How do you use a 'Local Block'?

728


How variables are declared in c?

576


Explain how can you restore a redirected standard stream?

594


what is a function method?give example?

1918


What are comments and how do you insert it in a C program?

747


What is fflush() function?

649


What are loops c?

618


What is c method?

539


Tell me what is null pointer in c?

617