0% found this document useful (0 votes)
8 views3 pages

String Programs G11

The document outlines a series of programming tasks related to string manipulation, including counting vowels, replacing characters, and analyzing word lengths. It also describes a class named 'Coding' that performs operations on a word, displaying its characters and their ASCII values. Additionally, it includes specific examples and methods for implementing these tasks in code.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

String Programs G11

The document outlines a series of programming tasks related to string manipulation, including counting vowels, replacing characters, and analyzing word lengths. It also describes a class named 'Coding' that performs operations on a word, displaying its characters and their ASCII values. Additionally, it includes specific examples and methods for implementing these tasks in code.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

String programs:

1. WAP to take a sentence and print each word in different line.


2. WAP to take a word and print the number of vowels.
3. WAP To take a sentence and print the number of vowels in each
word.
4. WAP To input a string and print each word of the string and the
number of characters present in it.
5. WAP to input a string and print the shortest and the longest word of
a sentence along with their length.
6. WAP to take a sentence and a word and insert the word as the
second word in the sentence.
7. WAP to accept a string in lowercase and replace letter as per the
table and display the new string.

Original letter Replace letter


a !
e @
i #
o $
u %
8. WAP to accept the string and display
a. No of lowercase letters.
b. No of uppercase letters.
c. No of digits.
d. No of special character.
9. WAP to accept a string and make the following changes:
a. Each letter of the string changes to the opposite case
b. Each digit changes to the next higher digit and ‘9’ to ‘0’
c. Single blank is replaced by “&”
10.

11. Consider the sentence as given below:


Blue bottle is in Blue bag lying on Blue carpet
Write a program to assign the goven sentence to a string variable.
Replave the word Blue with Red at all the occurrences, Display the
new string as shown below: Red bottle is in Red bag lying on Red
carpet.
12. Write a program to display the given pattern:

13.

14.
15. Design a class Coding to perform some string related
operations on a word containing alphabets only.

Example:
INPUT: “Java”
OUTPUT:
Original word: Java
J = 74
a = 97
v = 118
a = 97
Lowest ASCII code: 74
Highest ASCII code: 118

Some of the members of the class are given below.

Class name: Coding


Data members/instance variables:
wrd: stores the word
len: stores the length of the word
Methods/Member functions:
Coding(): constructor to initialize the data members with legal initial
values
void accept(): to accept a word
void find(): to display all the characters of ‘wrd’ along with their ASCII
codes. Also display the lowest ASCII code and the highest ASCII code, in
‘wrd’
void show(): to display the original word and all the characters of ‘wrd’
along with their ASCII codes. Also display the lowest ASCII code and the
highest ASCII code in ‘wrd’, by invoking the function find()

You might also like