0% found this document useful (0 votes)
124 views

String Assignment

The document contains 9 programming problems: 1. Write a program to count vowels, consonants, numbers, and other characters in a string. 2. Write a program to increment all numbers in a string by 1. 3. Write a function to replace multiple consecutive characters with a single character in a string. 4. Write a program to print the first non-repeating character in a string. 5. Write a program to print the length of each word in a sentence. 6. Write a program to check if a string is formed by concatenating the same string 3 times. 7. Write a program to reverse the case of each character in a string. 8. Write

Uploaded by

Swapnil Valwe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

String Assignment

The document contains 9 programming problems: 1. Write a program to count vowels, consonants, numbers, and other characters in a string. 2. Write a program to increment all numbers in a string by 1. 3. Write a function to replace multiple consecutive characters with a single character in a string. 4. Write a program to print the first non-repeating character in a string. 5. Write a program to print the length of each word in a sentence. 6. Write a program to check if a string is formed by concatenating the same string 3 times. 7. Write a program to reverse the case of each character in a string. 8. Write

Uploaded by

Swapnil Valwe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CDAC MUMBAI

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

4. 5. Given a string, print the first non-repeating character in the string.


Input: "aabbccdeeff", Output: d
Input: "aabbccddeeffgg", Output: "Not found"

5. Write a program which prints the length of each word in a sentence.


Input: I am a Java programmer
Output: 1 2 1 4 10

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"

8. Write a program to reverse a string.


Input : "hello"
Output : "olleh"
Input : "Hello World"
Output : "dlrow olleh"

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'

You might also like