Answer to Question #185382 in C# for angelo r reyes

Question #185382

Write a program that takes data, a word at a time and reverses the words of the line. Sample input/output dialogue: Input string value: birds and bees


Reversed: bees and birds


1
Expert's answer
2021-04-27T16:13:48-0400
using System;

namespace Test
{
    class ReverseTest
    {
        static void Main()
        {
            Console.Write("Input string value: ");
            string line = Console.ReadLine();

            string[] words = line.Split(new char[] {' ', '\t'});

            Console.Write("Reversed:");

            for(int i = words.Length - 1; i >= 0; --i)
            {
                Console.Write(" " + words[i]);
            }

            Console.WriteLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS