Javatpoint Logo
Javatpoint Logo

Q. Program to count the total number of punctuation characters exists in a string.

In this program, all the subsets of the string need to be printed. The subset of a string is the character or the group of characters that are present inside the string. For example, all possible subsets of a string "FUN" will be F, U, N, FU, UN, FUN.

Algorithm

  1. Define a string.
  2. If any character in the string is matched with (! , . , ' , - , " , ? , ; ) , increment the count by 1.
  3. Print the count.

Complexity:

O(n)

Solution

Python

Output:

Total number of punctuation characters exists in string: 
4

C

Output:

Total number of punctuation characters exists in string: 4

JAVA

Output:

Total number of punctuation characters exists in string: 4

C#

Output:

Total number of punctuation characters exists in string: 4

PHP

Output:

Total number of punctuation characters exists in string: 4

Next TopicPrograms List




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials