Program to find the product of ASCII values of characters in a string | C ++ program to find product of ASCII value of characters in string ; Function to find product of ASCII value of characters in string ; Traverse string to find the product ; Return the product ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long productAscii ( string str ) { long long prod = 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { prod *= ( int ) str [ i ] ; } return prod ; } int main ( ) { string str = " GfG " ; cout << productAscii ( str ) ; return 0 ; }