write a C code
to reverse a string using a recursive function, without
swapping or using an extra memory.
Answer Posted / 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 |
Post New Answer View All Answers
What is meant by operator precedence?
Why is python slower than c?
what do you mean by enumeration constant?
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
What is the purpose of macro in C language?
When should you use a type cast?
how to count no of words,characters,lines in a paragraph.
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
If errno contains a nonzero number, is there an error?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
What are the scope of static variables?
What does a function declared as pascal do differently?
a program that can input number of records and can view it again the record
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
If fflush wont work, what can I use to flush input?