BT_String
BT_String
2. Write a C# Sharp program to find the length of a string without using a library function.
Test Data :
Input the string : ueher.com
Expected Output :
4. Write a program in C# Sharp to print individual characters of the string in reverse order.
Test Data :
Input the string : ueher.com
Expected Output :
m o c . e c r u o s e r 3 w
1
Total number of words in the string is : 3
6. Write a program in C# Sharp to compare two strings without using a string library functions.
Test Data :
Input the 1st string : This is first string
Input the 2nd string : This is first string
Expected Output :
7. Write a program in C# Sharp to count the number of alphabets, digits and special characters in
a string.
Test Data :
Input the string : Welcome to ueher.com
Expected Output :
2
10. Write a C# Sharp program to find the maximum number of characters in a string.
Test Data :
Input the string : Welcome to ueher.com.
Expected Output :
12. Write a C# Sharp program to read a string through the keyboard and sort it using bubble sort.
Test Data :
Input number of strings :3
Input 3 strings below :
abcd
zxcv
mnop
Expected Output :
13. Write a program in C# Sharp to extract a substring from a given string without using the
library function.
Test Data :
Input the string : This is a test string
Input the position to start extraction :5
Input the length of substring :5
Expected Output :
3
14. Write a C# Sharp program to check whether a given substring is present in the given string.
Test Data :
Input the string : This is a Test String
Input the substring to search : Test
Expected Output :
15. Write a C# Sharp program to read a sentence and replace lowercase characters with
uppercase and vice-versa.
Test Data :
Input the string : This is a string
Expected Output :
17. Write a program in C# Sharp to search for the position of a substring within a string.
Test Data :
Input a String: this is a string
Input a substring to be found in the string: is
Expected Output :
18. Write a C# Sharp program to check whether a character is an alphabet and not and if so,
check for the case.
Test Data :
Input a character: Z
4
Expected Output :
19. Write a program in C# Sharp to find the number of times a substring appears in a given
string.
Test Data :
Input the original string : this is original string
Input the string to be searched for : str
Expected Output :
20. Write a program in C# Sharp to insert a substring before the first occurrence of a string.
Test Data :
Input the original string : this is a string
Input the string to be searched for : a
Input the string to be inserted : test
Expected Output :
21. Write a C# Sharp program to compare (less than, greater than, equal to) two substrings.
Expected Output :
22. Write a C# Sharp program to compare two substrings that only differ in case. The first
comparison ignores case and the second comparison considers case.
Expected Output :
5
23. Write a C# Sharp program to compare two substrings using different cultures and ignore the
substring case.
Expected Output :
24. Write a C# Sharp program to compare the last names of two people. It then lists them in
alphabetical order.
Expected Output :
25. Write a C# Sharp program to compare four sets of words by using each member of the string
comparison enumeration. The comparisons use the conventions of the English (United States)
and Sami (Upper Sweden) cultures.
Note : The strings "encyclopedia" and "encyclopedia" are considered equivalent in the en-US
culture but not in the Sami (Northern Sweden) culture.
Expected Output :
26. Write C# Sharp program to demonstrate that the Compare(String, String, Boolean) method is
equivalent to using ToUpper or ToLower when comparing strings.
Expected Output :
6
27. Write a C# Sharp program to demonstrate how culture affects comparisons.
Note : In Czech – Czech Republic culture, "ch" is a single character that is greater than "d".
However, in English - United States culture, "ch" consists of two characters, and "c" is less than
"d".
Expected Output :
28. Write a C# Sharp program to compare two strings in following three different ways produce
three different results.
Expected Output :
29. Write a C# Sharp program to compare three versions of the letter "I". The results are affected
by culture choice, whether the case is ignored, and whether an ordinal comparison is performed.
Expected Output :
StringComparison.CurrentCulture:
LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER DOTLESS I
(U+0131)
LATIN SMALL LETTER I (U+0069) is less than LATIN CAPITAL LETTER I (U+0049)
LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN CAPITAL LETTER I
(U+0
049)
30. Write a C# Sharp program to demonstrate that you compare ordinals and compare using
different sort orders.
7
Expected Output :
CompareOrdinal("xyz"[1], "XYZ"[1]):
'y' is greater than 'Y'
Compare("xyz"[1], "XYZ"[1]):
'y' is less than 'Y'
31. Write a C# Sharp program to perform an ordinal comparison of two strings that only differ in
case.
Expected Output :
Compare the numeric values of the corresponding Char objects in each string.
str1 = 'JAVA', str2 = 'python'
String 'JAVA' is less than String 'python'.
32. Write a C# Sharp program to compare a given string with a set of strings.
Expected Output :
33. Write a C# Sharp program to compare the current string instance with another string.
Expected Output :
34. Write a C# Sharp program to concatenate three objects, objects with a variable and a 3-
element object array.
Expected Output :
8
Using the English (United Kingdom) - "en-GB" culture:
Case sensitive:
The string to search ends with the target string: False
.........
Expected Output :
36. Write a C# Sharp program to concatenate three strings and display the result.
Expected Output :
Expected Output :
38. Write a C# Sharp program to determine whether the string "birds" is a substring of a familiar
string.
Expected Output :
'birds' is in the string 'Kill two birds with one stone': True
'birds begins at character position 10
39. Write a C# Sharp program to create two string objects with different values.
When it calls the Copy method to assign the first value to the second string, the output indicates
that the strings represent different object references. However, their values are now equal. On the
9
other hand, when the first string is assigned to the second string, the two strings have identical
values. This is because they represent the same object reference.
Expected Output :
s1 = 'JAVA'
s2 = 'Python''
Expected Output :
41. Write a C# Sharp program to indicate whether each string in an array ends with a period (".").
Expected Output :
42. Write C# Sharp program to check whether a string occurs at the end of another string.
Expected Output :
Case insensitive:
The string to search ends with the target string: False
Case insensitive:
The string to search ends with the target string: False
10
43. Write a C# Sharp program to determine whether a string ends with a particular substring.
Note : The results are affected by the choice of culture, whether case is ignored, and whether an
ordinal comparison is performed.
Expected Output :
StringComparison.CurrentCulture:
"xyzPQR" ends with "PQR".
"xyzPQR" ends with "PQR".
.......
44. Write a C# Sharp program to get the longest Palindromic substring from a given string.
From Wikipedia:
In computer science, the longest palindromic substring or longest symmetric factor problem is
the problem of finding a maximum-length contiguous substring of a given string that is also a
palindrome. For example, the longest palindromic substring of "bananas" is "anana". The longest
palindromic substring is not guaranteed to be unique; for example, in the string "abracadabra",
there is no palindromic substring with length greater than three, but there are two palindromic
substrings with length three, namely, "aca" and "ada".
Expected Output :
11
Expected Output :
46. Write a C# Sharp program to remove duplicate characters from a given string.
Expected Output :
47. Write a C# Sharp program to find the length of the longest substring without repeating
characters in a given string.
Expected Output :
48. Write a C# Sharp program to reverse the case (upper->lower, lower->upper) of all the
characters in a given string.
Expected Output :
12
Original string: PHP
After reversing the case of all characters of the said string: php
49. Write a C# Sharp program to find the central character(s) in a given string. Return the middle
character if the string length is odd and return two middle characters if the string length is even.
Expected Output :
Original string: C#
Middle character(s) of the said string: C#
50. Write a C# Sharp program to find the maximum and minimum number from a given string of
numbers separated by a single space.
Expected Output :
51. Write a C# Sharp program to check whether a given string is an “isograms” or not. Return
True or False.
From Wikipedia,
A heterogram (from hetero-, meaning 'different', + -gram, meaning 'written') is a word, phrase, or
sentence in which no letter of the alphabet occurs more than once. The terms isogram and
nonpattern word have also been used to mean the same thing.
Expected Output :
13
Original string: Python
Check the said string is an 'isograms' or not! True
Original string: C#
Check the said string is an 'isograms' or not! True
52. Write a C# Sharp program to convert the first character of each word in a given string to
uppercase.
Expected Output :
53. Write a C# Sharp program to find the position of a specified word in a given string.
Sample Example:
Position: 1 2 3 4 5 6 7 8
Expected Output :
Original string: The quick brown fox jumps over the lazy dog.
Position of the word 'fox' in the said string: 4
Position of the word 'The' in the said string: 1
Position of the word 'lazy' in the said string: 8
54. Write a C# Sharp program to alternate the case of each letter in a given string. The first letter
of this string must be uppercase.
14
Expected Output:
Original string: C# is used to develop web apps, desktop apps, mobile apps, games and much
more.
55. Write a C# Sharp program to reverse all the words of a given string with even length.
Expected Output:
Reverse all the words of the said string which have even length.:
#C Exercises
Original string: C# is used to develop web apps , desktop apps , mobile apps , games and much
more.
Reverse all the words of the said string which have even length.:
#C si desu ot develop web sppa , desktop sppa , elibom sppa , games and hcum more.
56. Write a C# Sharp program to find the longest common ending between two given strings.
Expected Output:
57. Write a C# Sharp program that takes a string and reverses the words of three or more lengths
in a string. Return the updated string. As input characters, only letters and spaces are permitted.
Sample Data:
("The quick brown fox jumps over the lazy dog") -> "ehT kciuq nworb xof spmuj revo eht yzal
15
god"
("Reverse the words of three or more") -> "esreveR eht sdrow of eerht or erom"
("ABcDef") -> "feDcBA"
58. Write a C# Sharp program to check if two given strings are anagrams or not.
Sample Data:
("wxyz", "zyxw") -> True
("pears", "spare") -> True
("stone", "tones") -> True
("cat", "rat") -> False
59. Write a C# Sharp program to reverse a positive integer and add the reversed number to the
original number.
Sample Data:
(456) - > 456654
(-123) -> "Input a positive number."
(10000) -> 1000000001
60. Write a C# Sharp program to count the number of duplicate characters (case sensitive)
including spaces in a given string. If there are no duplicates, return 0.
Sample Data:
("Red Green WHITE") -> 2
("ppqrrsttuuu") -> 4
("dow jones industrial average") -> 9
61. Write a C# Sharp program to count a specific string (case sensitive) in given text.
62. Write a C# Sharp program that displays all the characters with their respective numbers from
a string.
16
Sample Data:
("C Sharp") -> " 3 19 8 1 18 16"
("The quick brown fox jumps over the lazy dog.") -> " 20 8 5 17 21 9 3 11 2 18 15 23 14 6 15 24
10 21 13 16 19 15 22 5 18 20 8 5 12 1 26 25 4 15 7"
("HTML Tutorial") -> " 8 20 13 12 20 21 20 15 18 9 1 12 "
63. Write a C# Sharp program that takes a string that repeats a substring. Count the number of
times the substring appears.
Sample Data:
("aaaaaa") -> 6
("abababab") -> 4
("abcdabcdabcd") -> 3
64. Write a C# Sharp program to find the longest abecedarian word in a given array of words.
Sample Data:
({"abc", "abcd", "abcdef", "pqrstuv"}) -> "pqrstuv"
({"abc", "abcd", "abcdef", "pqrs"}) -> "abcdef"
({}) -> "Empty array!"
Sample Data:
(1435) -> "15th century"
(1567) -> "16th century"
(1921) -> "20th century"
(2014) -> "21st century"
66. Write a C# Sharp program to calculate the highest frequency of the character(s) in the words
of a given string.
Sample Data:
("aaaaaa") -> "a"
17
("Century of the said year") -> ""
("CPP Exercises”) -> "s, e, p"
67. Write a C# Sharp program that converts ASCII characters to hexadecimal values.
Sample Data:
(" Python") -> "50 79 74 68 6f 6e"
("Century of the year") -> 43 65 6e 74 75 72 79 20 6f 66 20 74 68 65 20 79 65 61 72
("CPP Exercises") -> 43 50 50 20 45 78 65 72 63 69 73 65 73
68. Write a C# Sharp program to check whether all characters in a given string are unique. If all
the characters are distinct, return “There is no similarity between any of the characters!”
otherwise if not unique, then:.
18