Programming Lab 4
Programming Lab 4
Expected Output:
The strings appears after sorting:
one
two
zero
13. Write a program in C++ to extract a substring from a given string.
Test Data:
Input the string: this is test string
Input the position to start extraction:9
Input the length of substring:4
Expected Output:
The substring retrieve from the string is: " test "
14. Write a C 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 be search: search
Expected Output:
The substring is not exists in the string.
15. Write a program in C++ to read a sentence and replace lowercase characters by uppercase and vice-
versa.
Test Data:
Input the string: This Is A Test String.
Expected Output:
The given sentence is : This Is A Test String.
After Case changed the string is: tHIS iS a tEST sTRING
16. Write a program in C++ to find the number of times a given word 'the' appears in the given string.
Test Data:
Input the string: The string where the word the present more than once.
Expected Output:
The frequency of the word 'the' is: 3
17. Write a program in C++ to remove characters in String Except Alphabets.
Test Data:
Input the string: w3resource.com
Expected Output:
After removing the Output String: wresourcecom
18. Write a program in C++ to Find the Frequency of Characters.
Test Data:
Input the string: This is a test string
Input the character to find frequency: i
Expected Output
The frequency of 'i' is: 3
19. Write a program in C++ to Concatenate Two Strings Manually.
Test Data:
Input the first string: this is string one
Input the second string: this is string two
Expected Output:
After concatenation the string is:
this is string one this is string two
20. Write a program in C++ to find the largest and smallest word in a string.
Test Data:
Input the string: It is a string with smallest and largest word.
Expected Output:
The largest word is 'smallest'
and the smallest word is 'a'
in the string: 'It is a string with smallest and largest word.'.
Expected Output:
Strings or words after split by space are:
this
is
a
test
string .
32. Write a C programming to find the repeated character in a given string.
Test Data:
Input a string: w3resource
Expected Output:
Input a string: The first repetitive character in w3resource is: r
33. Write a C programming to count of each character in a given string.
Test Data:
Input a string: w3resource
Expected Output:
Enter a str1ing: The count of each character in the string w3resource is
w 1
3 1
r 2
e 2
s 1
o 1
u 1
c 1
34. Write a C programming to convert vowels into upper case character in a given string.
Test Data:
Input a string: w3resource
Expected Output:
Input a sentence: The original string:
w3resource
After converting vowels into upper case the sentence becomes:
w3rEsOUrcE