> Program in turbo C++ : Enter a sentence containing digits at some places, and computer should display and find sum of al

Program in turbo C++ : Enter a sentence containing digits at some places, and computer should display and find sum of al

Posted at: 2014-12-18 
#include //for cin, cout

#include // for strlen

#include //for getch

int main()

{

int i,sum=0;

char str[50];

cout<<"Enter the string :";

cin>>str;

for(i=0;i
{

if(str[i]>=48 && str[i]<=57)

sum+=(str[i]-48);

}



cout<<"\nSum of all the digits = "<


getch();

}

nt sum, number;

. . .

for(sum=0; number>0; sum+=number%10, number/=10);

. . .