How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / mahesh auti
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(void)
{
char str1[] = "Mahesh";
char str2[80], *p1, *p2;
clrscr();
p1 = str1 + strlen(str1) - 1;
p2 = str2;
while(p1 >= str1)
*p2++ = *p1--;
*p2 = '\0';
printf("%s %s", str1, str2);
getch();
return 0;
}
| Is This Answer Correct ? | 26 Yes | 25 No |
Post New Answer View All Answers
State the difference between realloc and free.
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 is the difference between exit() and _exit() function in c?
How can you find out how much memory is available?
What is hungarian notation? Is it worthwhile?
What happens if you free a pointer twice?
What is floating point constants?
What are disadvantages of C language.
Why is C language being considered a middle level language?
Why is main function so important?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Are pointers integer?
What are near, far and huge pointers?
What is the purpose of macro in C language?
Explain the use of keyword 'register' with respect to variables.