ALCATRAZ1 - SUM OF DIGITS
You are being given a number N. (1<=N<=10^50) . You have to print the sum of digits of that particular number.
Input
The first line will contain T, the number of testcases (T<10) . The next T lines will contain the numbers whose sum of digits you have to calculate .
Output
Output T lines containing the Sum of Digits of the numbers .
Example
Input: 3 123123123 3434 1234567890 Output: 18 14 45
hide comments
amr2019:
2017-08-31 02:40:00
just convert char to int by sub it '0' and sum the all digits |
|
mike_computer:
2017-08-13 12:17:30
Hello, for c++ , use cstring than cin.getline(),than strlen to read till the end than add sum+=s[i]-'0' |
|
lopi_8:
2017-08-12 00:19:17
ez
|
|
pkenil96:
2017-08-08 13:40:35
Used string and converted each character to an integer and added to the sum..!!
|
|
soham_12345:
2017-07-16 07:00:27
ac in one go..python rocks
|
|
nimisha03:
2017-06-14 22:29:23
Plz anyone give one example how to use type casting?The one i m applying is not working!!
|
|
drjaat:
2017-05-30 19:08:48
time limit exceded :(
|
|
hrishabh:
2017-05-11 10:27:00
ac in one go...do in python |
|
anmoldua:
2017-04-27 20:05:32
check the limit i.e 10^50 all newbies |
|
ameyanator:
2017-03-16 08:26:12
easy af! |
Added by: | Alcatraz |
Date: | 2016-11-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |