Char - C# Programming Exercise

This exercise in C# aims to develop a program that asks the user for three letters and displays them in reverse order. The user will input one letter at a time, and the program, using control structures and data manipulation, will process the information to display the letters in the reverse order of their input.

This type of exercise is useful for practicing data manipulation in C#, such as reversing sequences, and for reinforcing user input handling. Additionally, it teaches how to work with strings and characters, fundamental skills in programming to process and transform data in real-world applications. This exercise is ideal for beginners looking to enhance their basic data manipulation skills in C#.

 Category

Basic Data Types

 Exercise

Char

 Objective

Write a C# program to ask the user for three letters and display them in reverse order.

 Write Your C# Exercise

using System;  // Import the System namespace to use basic classes like Console

class Program  // Define the main class of the program
{
    static void Main()  // The entry point of the program
    {
        // Ask the user to enter the first letter
        Console.Write("Enter the first letter: ");
        char letter1 = Console.ReadKey().KeyChar;  // Read a character input from the user

        // Ask the user to enter the second letter
        Console.Write("\nEnter the second letter: ");
        char letter2 = Console.ReadKey().KeyChar;  // Read a character input from the user

        // Ask the user to enter the third letter
        Console.Write("\nEnter the third letter: ");
        char letter3 = Console.ReadKey().KeyChar;  // Read a character input from the user

        // Display the letters in reverse order
        Console.WriteLine($"\nThe letters in reverse order are: {letter3} {letter2} {letter1}");  // Show the letters in reverse order
    }
}

 Share this C# exercise

 More C# Programming Exercises of Basic Data Types

Explore our set of C# programming exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of C#. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in C#.

  •  Triangle

    This exercise in C# aims to develop a program that prompts the user for a symbol and a width, and then displays a decreasing triangle of the spec...

  •  Password as string

    This exercise in C# aims to develop a program that asks the user for their username and password (both as strings) and repeats the prompt as many...

  •  Password 5 attempts

    This C# exercise involves creating a program that prompts the user for their username and password, both as strings. If the entered credentials do not m...

  •  Calculator - if

    This C# programming exercise requires creating a program that asks the user for two numbers and an operation to perform on them. The supported operations are ...

  •  Calculator - switch

    In this C# programming exercise, you need to create a program that asks the user for two numbers and a mathematical operation to perform between them. Supporte...

  •  Double

    In this C# programming exercise, you need to create a program that calculates the perimeter, area, and diagonal of a rectangle, given its widt...