We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, June 10, 2015

Reverse the Character in the Given sentence and remove the space.

class Program 
    {

        static void Main(string[] args) 
        {

            string str = "", reverse = ""; 
            str = "honesty is the best policy"; 
            int num = str.Length - 1; 
             while (num >= 0) 
            {

                if (str[num] != ' ') 
                {

                    reverse = reverse + str[num]; 
                }

                num--; 
            }

            Console.WriteLine(reverse); 
            Console.ReadLine(); 

        } 

    }

No comments: