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
- Program to find the largest and smallest ASCII valued characters in a string
- Count characters in a string whose ASCII values are prime
- Find the sum of the ascii values of characters which are present at prime positions
- Convert a string to hexadecimal ASCII values
- Check if a string contains only alphabets in Java using ASCII values
- Count pairs of characters in a string whose ASCII value difference is K
- 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
- Map function and Dictionary in Python to sum ASCII values
- Sums of ASCII values of each word in a sentence
- Print each word in a sentence with their corresponding average of ASCII values
- Minimize ASCII values sum after removing all occurrences of one character
- Count the number of words having sum of ASCII values less than and greater than k
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.