String Based Pro1 - 24156236
String Based Pro1 - 24156236
EASY
1. Write a program to input a sentence and display the number of vowels and the number of
consonants present in it.
2. Write a program to display the Frequency of each vowel present in a sentence.
3. Write a program to input a sentence and display the number of capital letters, number of small
letters, number of digits and the number of special characters.
4. Write a program to display the number of words in a sentence.
5. Write a program to input a string from the user and check whether it is a palindrome or not. A string
is said to be palindrome if it reads the same from left to right and vice-versa
MODERATE
6. Write a program to input a string and display it after replacing each letter with the next letter in
cyclic order.
for e.g. if input is “zealous” output should be “aibmpvt”
7. Wriite a program to input a sentence and display it after reversing the order of the words in the
sentence. For e.g. If input is “Java is fun” then the output should be “fun is Java“
8. Write a program to input a string and display it after arranging all the letters in alphabetical order. If
input is computer then the output should be cemoprtu
9. Write a program to calculate the charges for a telegraph message according to the
following conditions.
Up to 10 words, the charge is Rs. 3.00 and 0.40 per additional words.
Your program should input the message from the console and display the charge
10. Write a program to input a sentence and display all the words containing at least two vowels.
11. Write a program to input a sentence and display it after replacing each “is” with „was”. (replace
only words)
12. Write a program to input a sentence and make the first letter of each word a capital letter and
display it.
For eg. If the input is “India is my country” the output should be “India Is My Country”
13. Write a program to accept a sentence and print only the first letter of each word of the sentence in
capital letters separated by a full stop.
Example :
INPUT SENTENCE : “This is a cat”
OUTPUT : T.I.A.C.
14. Write a program to input the first name, middle name and last name of a person and display the last
name with the initials.
For example :
Input - Jawahar Lal Nehru
Output - J.L. Nehru
15. Write a program to input a string and to create another string object that contains all the characters
of the first siring in the given order. ( capital letters, small letters, digits, space characters and other
special characters)
TOUGH
16. Write a program to input a string and display it after replacing each vowel with the next vowel, and
each consonant with the next consonant in cyclic order. Assume that the string contains only small
letters.
for e.g. if input is “zealous” output should be “biemuat”
17. Write a program to accept a sentence and display the word with the maximum number of vowels
present in it.
18. An anagram is a word or a phrase made by transposing the letters of another word or phrase; for
example, "parliament" is an anagram of "partial men," and "software" is an anagram of "swear oft."
Write a program that figures out whether one string is an anagram of another string. The program
should ignore white space and punctuations.
19. Write a program to find the number of times a given sub-string is repeated in a string
20. Write a program to input and store the names of all the students in your class in an array namelist
and the corresponding admission numbers in an array admn. Search for a name inputted by the
user in the namelist using binary search algorithm. If found display “search successful” and print
the name along with the admission number, otherwise display “ Search unsuccessful. Name not
enlisted”
21. Write a program to input a sentence and display all the words with at least one pair of consecutive
letters.
For eg. If the sentence is “A program is a set of instructions given to a computer to get the required
work done ” the output should be - instructions
22. Write a program to input a string and encode it by replacing each letter by converting it to opposite
case and then by the next letter in a circular way.
For e.g. if the input is “AbZ5” the output should be “bCa5”
23. Write a program to input a sentence display it after removing all the articles(a/an/the) from the
inputted sentence.
input :-“The maximum runs scored by an Indian batsman in a
test innings is 326”
output:- :-“ maximum runs scored by Indian batsman in
test innings is 326”
24. A word is said to be “abecedarian” if the letters in the word appear
in alphabetical order. For example, the following are all 6-letter English abecedarian
words.
abdest, acknow, acorsy, adempt, adipsy, agnosy, befist, behint, beknow,
bijoux, biopsy, cestuy, chintz, deflux, dehors, dehort, deinos, diluvy,
dimpsy
Writ a program for checking whether a given word (String) is abecedarian,
assuming that the word contains only lower-case letters.
25. The Captain Crunch decoder ring works by taking each letter in a string and
adding 13 to it. For example, ‟a‟ becomes ‟n‟ and ‟b‟ becomes ‟o‟. The letters
“wrap around” at the end, so ‟z‟ becomes ‟m‟.
Write a program that takes a String and that returns a new String containing the
encoded version. You should assume that the String contains upper and lower
case letters, and spaces, but no other punctuation. Lower case letters should
be tranformed into other lower case letters; upper into upper. You should not
encode the spaces.
26. “abstentious ” is a special word because it contains all the vowels that too in the correct order. Write
a program to input a word and check whether it is a special word or not.