Uploaded by myoandyma2122004

Practice Session-9

advertisement
Practice-9 (Strings)
CSE 1030
I Semester 2022-2023
(10 points)
Problem 1. Wrtie a program to read and print the text until a * is
encountered. Also count the number of characters in the text entered.
Output:
Enter * to end
Enter the text: Hi there*
The text is: Hi there
The count of character is: 8
Problem 2. Write a program to read a sentence. Then count the number
of words in the sentence.
Output:
Enter the sentence: How are you
The total count of words is: 3
Problem 3. Write a program to read multiple lines of text until a * is
entered. Then count the number of characters, words, and lines in the text.
Output:
Enter the text: Hi there*
The total count of words is: 2
The total count of lines is: 1
The total count of characters is: 8
Problem 4. Write a program to enter a text that has commas. Replace all
the commas with semi commas and then display the text.
Output:
Enter the text: Hello, How are you
The copied text is: Hello; How are you
Problem 5. Write a program to find whether a given string is a
palindrome or not.
Output:
Enter the string: madam
PALINDROME
Enter the string: hello
NOT PALINDROME
Enter the string: 151
PALINDROME
Enter the string: 1511
NOT PALINDROME
Download