Basic Programming C# Examples

C# Program that takes letters & display them in reverse order

The Program in C# Program that takes letters & display them in reverse order in Given array is given below:

using System;

namespace ReverseLetters
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Codeauri Family, enter a word here to find it in reverse order:");
            string word = Console.ReadLine();
            char[] wordArray = word.ToCharArray();
            Array.Reverse(wordArray);
            Console.WriteLine("Okay,the word in reverse order is: ");
            Console.WriteLine(new string(wordArray));
        }
    }
}

Output:

Hello Codeauri Family, enter a word here to find it in reverse order:coderecode
Okay,the word in reverse order is:
edoceredoc

Pro-Tips💡

Here are the step by step execution of above program:

  1. The using System; statement is a directive that tells the compiler to include the System namespace in the program.
  2. The namespace ReverseLetters defines a namespace that encapsulates the Program class.
  3. The class Program contains a Main method, which is the entry point of the application.
  4. The Main method starts by displaying a message asking the user to enter a word.
  5. The user’s input is stored in a string variable called “word”.
  6. The ToCharArray() method is used to convert the string into a character array.
  7. The Array.Reverse() method is used to reverse the order of the elements in the character array.
  8. The new string() constructor is used to create a new string from the reversed character array.
  9. Finally, the reversed word is displayed to the user using Console.WriteLine().

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

Programming Languages( Types, Pros and Cons)-Codeauri

What are the types or levels of Programming Languages? The types or levels of programming languages are divided into two types: Types Of Programming Languages: 1.Machine-level Language :1st…

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X