Where did I go wrong?

Where did I go wrong in the following submission?Can someone please explain?Thanks.This is my solution

There are several things wrong with your submission:

  1. for(i=0; i < sizeof(array); i++) you created an array of size 1000 and now reading the entire array while you should be reading only the string. Use strlen instead of sizeof.
  2. sum+=int array[i] you are adding ASCII values of digit, while you should be adding the magnitude, use int(ar[i] - '0') instead.
  3. printf("%d",sum) you need to print the answer for each test case in a new line, use printf("%d\n", sum) instead.

Correct code:

int main() {
    int T;
    while(T--) {
        char array[1000];
        int sum = 0;
        for(int i = 0 ; i < strlen(array); i++) {
            if(isdigit(array[i])) {
                sum += int(array[i] - '0');
        printf("%d\n", sum);
    return 0;

Thanks buddy