A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to check the length of a given string is odd or even. Return 'Odd length' if the string length is odd otherwise 'Even length'
Q:

Write a C# Sharp program to check the length of a given string is odd or even. Return 'Odd length' if the string length is odd otherwise 'Even length'

0

Write a C# Sharp program to check the length of a given string is odd or even. Return 'Odd length' if the string length is odd otherwise 'Even length'

Sample Output:

Original string: PHP
Convert the letters of the said string into alphabetical order: Odd length
Original string: javascript
Convert the letters of the said string into alphabetical order: Even length
Original string: python
Convert the letters of the said string into alphabetical order: Even length

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Original string: PHP");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("PHP"));
            Console.WriteLine("Original string: javascript");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("javascript"));
            Console.WriteLine("Original string: python");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("python"));
        }
        public static string test(string word)
        {
            int length = word.Length;
            if (length % 2 == 0)
            {
                return "Even length";
            }
            else
            {
                return "Odd length";
            }
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now