C#: Display three letters in reverse order
C# Sharp Basic Data Types: Exercise-1 with Solution
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/csharp-exercises/data-types/csharp-data-type-exercise-1.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics