How to convert this code into c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
30th May 2019, 5:41 AM
G.Vamshi Krishna
G.Vamshi Krishna - avatar
12 Answers
+ 9
Aad Hoogenboom Serena Yvonne Coder VEDANG Jamie💐 Jay Plzz try it guys It's important for him
30th May 2019, 5:47 AM
//(AnOnYmOuS);
30th May 2019, 6:10 AM
//(AnOnYmOuS);
+ 7
And that's the problem Adding digits is simple Adding number is confusing
30th May 2019, 7:10 AM
//(AnOnYmOuS);
+ 7
No problem just need to make an logic which read string and when face any digit poped that into an variable, then when other digit comes that will add to that variable. will update and get back to you in some time after launch till that time if you get solution then good else I'll edit and post that Have some 🍎 🍎 🍎 🍎
30th May 2019, 7:13 AM
DishaAhuja
DishaAhuja - avatar
+ 7
DishaAhuja Thanks sis
30th May 2019, 7:14 AM
//(AnOnYmOuS);
+ 5
G.Vamshi Krishna Mohd Shahzer hi, I didn't able to find code, ping me if you post the correct link of the code Till that have these 🍎 🍎 🍎
30th May 2019, 6:08 AM
DishaAhuja
DishaAhuja - avatar
+ 5
Mohd Shahzer You want to convert it into C then you can use an shorter way #include <stdio.h> int main() { char str[80]; int count,n=0,sum=0; printf("Enter the string"); scanf("%s",str); for(count=0;str[count]!='\0'; count++) { if((str[count]>='0') && (str[count]<='9')) { n += 1; sum += (str[count] - '0'); } } printf("NO. of Digits in the string=%d\n",n); printf("Sum of all digits=%d\n",sum); } #include <stdio.h>   int SumDigits(unsigned long long n, const int base) { int sum = 0; for (; n; n /= base) sum += n % base; return sum; }   int main() { printf("%d %d %d %d %d\n", SumDigits(12345, 10), SumDigits(123045, 10), SumDigits(0xfe, 16), SumDigits(0xf0e, 16) ); return 0; } If you looking for any alternative way ping me Have some 🍎 🍎 🍎 🍎
30th May 2019, 6:56 AM
DishaAhuja
DishaAhuja - avatar
+ 3
G.Vamshi Krishna Mohd Shahzer here is your updated code in simple regex use you can use regex expression to extract the digits %*[^0-9] https://code.sololearn.com/cbE14MaLUVvC/?ref=app Have some 🍎 🍎 🍎 🍎 🍎
30th May 2019, 8:11 AM
DishaAhuja
DishaAhuja - avatar
+ 1
Anyone try this
30th May 2019, 5:42 AM
G.Vamshi Krishna
G.Vamshi Krishna - avatar
+ 1
I want to add double numbers
30th May 2019, 7:05 AM
G.Vamshi Krishna
G.Vamshi Krishna - avatar
+ 1
TS23NA10 Output 23+10=33
30th May 2019, 7:06 AM
G.Vamshi Krishna
G.Vamshi Krishna - avatar
0
If input is TS47S2378 Output 47 +2378 =2425
30th May 2019, 10:17 AM
G.Vamshi Krishna
G.Vamshi Krishna - avatar