String Assignment
String Assignment
1. Write a program which takes a string and prints the number of vowels, consonants(non-vowels).
numbers and other characters.
Input: "Hello world 37 1!"
Output: Vowels: 3
Consonants: 7
Numbers: 2
Others: 6
2. Given a string which contains numbers from 0 to 9 expressed as words, output a string which
contains all numbers incremented by 1
Input : There are three bugs and nine features
Output : There are four bugs and ten features
3. Write a function to replace multiple consecutive occurrences of characters with a single character
Input : abccddde
Output : abcde
Input : aabbbbaaa
Output : aba
6. Given a string, check whether it is a formed by concatenating the same string 3 times.
Input: "abcabcabc", Output: true (abc is repeated 3 times)
Input: "abcdabcdabcd", Output: true (abcd is repeated 3 times)
Input: "andandan', Output: false
CDAC MUMBAI
7. Given a string , output another string where the case of the characters is reversed.
Input : "Hello World"
Output : "hELLO wORLD"
9. Write a program which accepts two string and prints all unique characters which are common in
both stirngs.
Input 1 : "hello world"
Input 2 : "lot of work"
output : 'l' , 'o' , 'w' , 'r'