Given a string str. The task is to find the product of ASCII values of characters in the string.
Input : str = "IS" Output : 6059 73 * 83 = 6059 Input : str = "GfG" Output : 514182
The idea is to start with iterating through characters of the string and multiply their ASCII values to a variable namely, prod. Hence, return prod after the complete iteration of string.
Note: If the string is large, the program may cause segmentation fault because of the limited size of an int.
Below is the implementation of the above approach:
Time Complexity: O(N), where N is the length of string.
- Average of ASCII values of characters of a given string
- Count characters in a string whose ASCII values are prime
- Program to find the largest and smallest ASCII valued characters in a string
- Convert a string to hexadecimal ASCII values
- Check if a string contains only alphabets in Java using ASCII values
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Sum of the alphabetical values of the characters of a string
- Sum and Product of Prime Frequencies of Characters in a String
- Sums of ASCII values of each word in a sentence
- Map function and Dictionary in Python to sum ASCII values
- Print each word in a sentence with their corresponding average of ASCII values
- Count the number of words having sum of ASCII values less than and greater than k
- Minimize ASCII values sum after removing all occurrences of one character
- Find the smallest window in a string containing all characters of another string
- Sub-strings having exactly k characters that have ASCII value greater than p
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.