Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reversed String Palindrome

Project on Reverse String Palindrome. This code is a C# program that takes a user input string, reverses it, and then checks whether the reversed string is a palindrome (reads the same forwards and backwards).

Here's a step-by-step breakdown of the code:

Namespace Declaration (namespace ReversedStringPalindrome): This is the namespace where the code resides. Namespaces provide a way to organize and group related code together.

Class Declaration (internal class Program):

This is the class containing the program's logic.

Main Method (static void Main(string[] args)):

This is the entry point of the program, where the execution starts.

User Input and Reversing:

The project prompts the user to input a string using Console.WriteLine("Welcome to Reverse String App. Please insert a string: ");. It reads the input string and converts it to uppercase using string insertedWords = Console.ReadLine().ToUpper();. It converts the input string to a character array using char[] stringArray = insertedWords.ToCharArray();. It reverses the character array using Array.Reverse(stringArray);. It creates a new string from the reversed character array using string reversedString = new string(stringArray);.

Output Original and Reversed Strings:

The program outputs the original input string using Console.WriteLine($"Inserted String: {insertedWords}\n");. It outputs the reversed string using Console.WriteLine($"Reversed String: {reversedString}");.

Palindrome Checking:

The program checks whether the reversed string is the same as the original input string to determine if it's a palindrome. This is done using bool checkPalindrome = reversedString == insertedWords;.

Result:

The program outputs whether the string is a palindrome or not based on the result of the palindrome check. If checkPalindrome is true, it prints "The string is a palindrome.". If checkPalindrome is false, it prints "The string is not a palindrome.".

In all, this code takes an input string, reverses it, checks if the reversed string is the same as the original input (which determines if it's a palindrome), and then provides output indicating whether the input string is a palindrome or not.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages