import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // YOUR CODE GOES HERE
        // Please take input and print output to standard input/output (stdin/stdout)
        // DO NOT USE ARGUMENTS FOR INPUTS
        // E.g. 'Scanner' for input & 'System.out' for output
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt(); ;
        for(int i = 1 ; i <= T ; i++){
            int N = sc.nextInt();
            int sum = 0 ;
            while(N>0){
                
                int last = N % 10 ;
                sum = sum + last;
                N = N / 10 ;
            }
            System.out.println(sum);

        }
        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: