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

String Practical

Some important questions for board class 12

Uploaded by

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

String Practical

Some important questions for board class 12

Uploaded by

Amita Barwan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

String Programs Assignment

Q.1. Write a program to input a natural number less than 1000 and then output it in
words. (2011)
Example: INPUT: 29
OUTPUT: TWENTY-NINE

Q.2. Write a program to accept a sentence which may be terminated by either ‘.’ ‘?’
or ‘!’ only. Any other character may be ignored. The words may be separated by more
than one blank space and are in UPPER CASE. (2014)
Perform the following tasks:
a) Accept the sentence and reduce all the extra blank space between two words
to a single blank space.
b) Accept a word from the user which is part of the sentence along with its
posi on number and delete the word and display the sentence.

Q.3. Input a paragraph containing ‘n’ number of sentences where (1 = < n < 4). The
words are to be separated with a single blank space and are in UPPERCASE. A
sentence may be terminated either with a full stop ‘.’ Or a ques on mark ‘?’ only. Any
other character may be ignored. Perform the following opera ons:
(2010)
a) Accept the number of sentences. If the number of sentences exceeds the limit,
an appropriate error message must be displayed.
b) Find the number of words in the whole paragraph
c) Display the words in ascending order of their frequency. Words with same
frequency may appear in any order.

Q.4. Write a program to accept a sentence which may be terminated by either '.', '?'
or '!' only. The words are to be separated by a single blank space and are in UPPER
CASE.
Perform the following tasks: (2020)
a) Check for the validity of the accepted sentence only for the termina ng
character.
b) Arrange the words in ascending order of their length. If two or more words
have the same length, then sort them alphabe cally.
c) Display the original sentence along with the converted sentence.

Q.5. Write a program to accept a sentence which may be terminated by either ‘.’, ‘?’
or ‘!’ only. The words are to be separated by a single blank space and are in
uppercase.
Perform the following tasks: (2019)
a) Check for the validity of the accepted sentence.
b) Convert the non-palindrome words of the sentence into palindrome words by
concatena ng the word by its reverse (excluding the last character).

Q.6. The names of the teams par cipa ng in a compe on should be displayed on a
banner ver cally, to accommodate as many teams as possible in a single banner.
Design a program to accept the names of N teams, where 2 < N < 9 and display them
in ver cal order, side by side with a horizontal tab (i.e. eight spaces). (2018)

Q.7. Write a program to accept a sentence which may be terminated by either '.', '?'
or '!' only. The words may be separated by more than one blank space and are in
UPPER CASE.
Perform the following tasks: (2016)
a) Find the number of words beginning and ending with a vowel.
b) Place the words which begin and end with a vowel at the beginning, followed
by the remaining words as they occur in the sentence.

Q.8. Read a single sentence which terminates with a full stop(.). The words are to be
separated with a single blank space and are in lower case. Arrange the words
contained in the sentence according to the length of the words in ascending order. If
two words are of the same length then the word occurring first in the input sentence
should come first. For both, input and output the sentence must began in upper case.
(2009)

Q.9. Write a program which takes a string (maximum 80 characters terminated by a


full stop. The words in this string are assumed to be separated by one or more blanks.
Arrange the words of the input string in descending order of their lengths. Same
length words should be sorted alphabe cally. Each word must start with an
uppercase le er and the sentence should be terminated by a full stop. (2005)

Q.10. Write a program to print a rectangle with diamond shape gap exactly at the
centre of the rectangle using a n input string with odd numbers of character not
exceeding 20. (2000)
Example:
Input: HAPPY-HAPPY
Output:
HAPPY-HAPPY
HAPPY HAPPY
HAPP APPY
HAP PPY
HA PY
A Y
HA PY
HAP PPY
HAPP APPY
HAPPY HAPPY
HAPPY-HAPPY

You might also like