C#: Display three letters in reverse order
Write a C# Sharp program that takes three letters and displays them in reverse order.
Sample Solution:-
C# Sharp Code:
using System;
public class Exercise1
{
public static void Main()
{
// Declare variables to store three letters
char letter, letter1, letter2;
// Prompt user to input the first letter
Console.Write("Input letter: ");
// Read and store the first letter input by the user
letter = Convert.ToChar(Console.ReadLine());
// Prompt user to input the second letter
Console.Write("Input letter: ");
// Read and store the second letter input by the user
letter1 = Convert.ToChar(Console.ReadLine());
// Prompt user to input the third letter
Console.Write("Input letter: ");
// Read and store the third letter input by the user
letter2 = Convert.ToChar(Console.ReadLine());
// Display the letters in reverse order
Console.WriteLine("{0} {1} {2}", letter2, letter1, letter);
}
}
Sample Output:
Input letter: a Input letter: b Input letter: c c b a
Visual Presentation:
Flowchart:
C# Sharp Code Editor:
Contribute your code and comments through Disqus.
Previous: C# Sharp Data Types Exercises
Next: Write a C# Sharp program that takes three letters as input and display them in reverse order.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics