6.10.
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
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Input string value: ");
string words = Console.ReadLine();
string[] s = words.Split(' ');
Array.Reverse(s);
string result = string.Join(" ", s);
Console.WriteLine("Reversed: {0}", result);
}
}
}
Comments
Leave a comment