Reverse of number using recursion method in C

c-techaravind
                                              To compile and execute the program, copy the code into a text file. Save the text file with the extinction .c (ex. program.c). Save your file in turboc2 or borland (it may your othe c-compiler). Now open you IDE (tc.exe) , goto file->pick file. Your source file will be loaded into IDE. Now you can compile and run the file easily.




#include <stdio.h>
#include <string.h>
#include <conio.h>
void reverse(char **s, int start, int last)
{
char *s2 = *s;
char tmp;
if (start >= last)
return;
tmp = s2[start];
s2[start] = s2[last];
s2[last] = tmp;
reverse(s, start + 1, last - 1);
}

int main()
{
char *s,a[10];
clrscr();
gotoxy(31,1);
printf("Reverce Number");
gotoxy(26,3);
printf("http:\\techaravind.blogsopt.com");
gotoxy(1,5);
printf("Enter the number:")
scanf("%s",&a);
s=&a;
reverse(&s, 0, strlen(s) - 1);
printf("%s\n", s);
getch();
}

0 comments:

Post a Comment

 
Etutos © 2010-2011