Sum of Digits https://www.codechef.com/problems/FLOW006

Hey! anyone please help me! Why is my code is not being accepted? It always says “Wrong Answer!”
and I am 100% sure that my code is correct!

Here’s my code in java:

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int T=in.nextInt();
int sum, num;
while(T-- > 0)
{
sum=0;
num=in.nextInt();
while(num%10!=0)
{
sum+=num%10;
num/=10;
}
System.out.println(sum);
}
}
}

https://www.codechef.com/problems/FLOW006

1 Like

Your condition for while is incorrect

Try

1
12056

Ohh! I see thanks Bro!

2 Likes