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'
- برمجة سي شارب
- برمجة
- 2021-05-15
- MarwaMohammed
الأجوبة
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";
}
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال