You are on page 1of 2

Computer Science (083)

Ass #6 - Strings & User Defined Functions


1. Write a program that uses function cap_alphabets( ) with one argument a sentence
terminated by . (dot) and prints the number of uppercase alphabets in a sentence.
2. Write a program that uses function small_alphabets( ) with one argument a sentence
terminated by . (dot) and prints the number of lowercase alphabets in a sentence.
3.

Write a program that uses function Words( ) with one argument a sentence terminated
by . (dot) which returns the number of words in a sentence.

4. Write a program that uses function Total_char( ) with one argument a sentence
terminated by . (dot) which returns the number of characters in a sentence.
5. Write a program that uses function Vowel( ) with one argument a string of maximum
255 characters which returns the number of vowels in the string.
6. Write a program that uses function Words_line( ) with one argument a string of
maximum 255 characters and prints the each word of the string on separate line.
7. The famous Sari shop Kala Niketan wishes to find out how many saris it is selling, each of
the colors; Red(R ), Blue(B), Green(G) and White(W). Write a program that uses a
function
Sari_color( ) with one argument a string in the form
GRYBBYGWRRBPBWPB and prints the output in the following form:
No. of Green Sarees : 2
No. of White Sarees : 2
No. of Red Sarees
: 3
No. of Blue Sarees
: 5
No. of Others
: 4
8. Write a program that uses a function Palindrome ( ) with one argument ---- a string and
prints whether it is a palindrome or not.
9. Write a program that uses a function Reverse ( ) with one argument --- a string and print
the reverse of each word in a string. For example:
Input String: Computer Science
Output String: retupmoC ecneicS
10. Write a program that uses a function Count ( ) with one argument ---- a string and prints
the number of occurrence of the word the in it. Do not count the in words like mother.
11. Write a program that uses a function Each_Vowel ( ) with one argument --- a string and
print the count of each vowel.
12. Write a program that uses a function Find ( ) with two arguments ---- a string and an
alphabetic char. It prints how many times the character appears in a string.
13. Write a program that uses a function MatchBraces ( ) function that checks for matching
braces in a parenthesized algebraic expression. It returns the value 1 if the match is
successful and 0 otherwise.

14. Write a program that uses a function Fun( ) with two arguments ---- a string and an
alphabetic char. It searches the given alphabetic character within the string and then
converts that occurrence of the character in its reverse case. For example, if input is
String ---- AabRa Ca dAbRa
Char ----- a
The output is ------ aAbRA CA dabRA
Hots:
1. Write a function Four_char_words( ) and Two_char_words( ) with one argument --- a
string having 4 distinct characters and prints all 4 letters and 2 letters words which can be
formed respectively from the 4 characters. No characters should be repeated in a word.

You might also like