A recursive function is a function which calls itself to work on the smaller function. This program reverses a string using a recursive function.
- class Program
- {
- static void Main(string[] args)
- {
- Program p = new Program();
- p.Fun();
- Console.WriteLine("\n");
- Console.ReadLine();
-
- }
- public void Fun()
- {
- char c;
- if ((c = Convert.ToChar(Console.Read())) != '\n')
- Fun();
- Console.Write(c);
- }
- }
- }
Hope you find this helpful.