Tuesday, May 22, 2012

The Below Is the program To Print Reverse of an Array

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace array_reverse
{
    class Program
    {

        public static string reverse(char[] mystring)
        {
               
                for (int i =mystring.Length -1; i >= 0; i--)
                {
                   
                   Console.Write(mystring[i]);
                }
           
          
            return mystring.ToString();
          
        }
        static void Main(string[] args)
        {
            char[] arr = new char[20];
            Console.WriteLine("Enter Elements to be reversed");
            arr=Console.ReadLine().ToCharArray();
            Console.WriteLine("The Reverse of the array is");
            reverse(arr);
            Console.ReadLine();
        }
    }  
    }




No comments:

Post a Comment