We always get maximum sum if we replace 5 with 6.
int maxSum = replaceDig ( x1 , 5 , 6 ) + replaceDig ( x2 , 5 , 6 ) ; cout << " Minimum ▁ sum ▁ = ▁ " << minSum ; cout << " nMaximum ▁ sum ▁ = ▁ " << maxSum ; }