Thursday 4 February 2021

String Questions

Q) Today, Monk went for a walk in a garden. There are many trees in the garden and each tree has an English alphabet on it. While Monk was walking, he noticed that all trees with vowels on it are not in good state. He decided to take care of them. So, he asked you to tell him the count of such trees in the garden. Note : The following letters are vowels: 'A', 'E', 'I', 'O', 'U' ,'a','e','i','o' and 'u'. Input: The first line consists of an integer T denoting the number of test cases. Each test case consists of only one string, each character of string denoting the alphabet (may be lowercase or uppercase) on a tree in the garden. Output: For each test case, print the count in a new line.

Q)  John is fond of vowels. In a line of text, he wanted to see all lower-case vowels in uppercase & vice-versa. Implement a C program to perform the following.

Input: India is my cOuntry

Output: indIA Is my country

 

Q2) Write a user-defined function in C to concatenate first n characters of string2 with string1 considering string1, string2 and n as arguments.

Q3) Write a program that extracts part of the given string from the specified index. For example, if the string is " Working with string is fun", then if from index 3, 4 characters are to be extracted then the program should return string as "king". Moreover, if the index from where the string is to be extracted is given and the number of characters to be extracted is 0 then the program should extract entire string from the specified index.

Q4) Array of Strings concept: Write a program to sort the color names given in set in alphabetical order Sample Input: violet, blue, green, orange, red, aqua. Sample Output: aqua, blue, green, orange, red, violet.

Q5) Consider two strings s1 and s2 and compare the 2 strings alphabetically without using and string handling functions (case insensitive comparison).

Sample Input: s1=” Hai” s2=”hai”

Sample Output: Both strings are similar

Q6) Implement a C program to reverse a given string using a user-defined recursive function.

Sample Input: KLU is in Guntur

Sample Output: rutnuG ni si ULK

No comments:

Post a Comment