Program to find the sum of all numbers present in the string | faceprep

Program to find the sum of all numbers present in the string | faceprep

The program to find the sum of all numbers present in the string is discussed here.

Given a string containing both numbers and alphabets, the task is to find the sum of all numbers present in the string.



Find the sum of all numbers present in a string


For example, consider the following :

Input:

abc45def5ghi32

Output:

82

Explanation:

The numbers 45, 5 and 32 are present in the string.

Sum = 45 + 5 + 32 = 82.

Algorithm to find the sum of all numbers present in the string

  • Input the string from the user.
  • Initialize sum = 0.
  • Find the numbers that are present in the string and add them to the sum.
  • Display sum.


face prep pro ad bannerClick here to learn more about FACE Prep PRO


Program to find the sum of all numbers present in the string

@@coding::1@@


Recommended Programs


Find the sum of all numbers present in a string

c