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

Saturday, June 13, 2015

Write a program in given a string change every word of the first letter in the capital letters?

class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the string");
            string str1 = Console.ReadLine();
            int s = 0;

            foreach (char num in str1)
            {
                if (num != ' ')
                {

                    if (num > 96 && num < 124)
                    {

                        if (s == 0)
                        {

                            Console.Write(Convert.ToChar(num - 32));
                            s++;
                        }
                        else
                        {
                            Console.Write(num);

                        }

                    }

                }

                else
                {

                    Console.Write(" ");
                    s--;

                }

            }

            Console.ReadLine();

        }


    }

Output:



No comments: