**New course!**Every coder should learn

**Generative AI!**

# Arrays

Guys, I need help: I have task to print an element of array with largest sum of digits. Here is my code, I tried to create subarray which shows sum of digits and it works, but when I run this program it prints "Largest sum of digits has element 0", (in my native: "Najveći zbir cifara ima element 0").I think it is the matter with last condition, variable is lost in memory or somewhat. Could someone help me with that I would greatly appreciate.Here is code:#include <stdio.h> int main() { int x[20]; int i,j,n,k,maks; int sum[20]; printf("Unesite broj elemenata niza:"); scanf("%d",&n); i=0; while(i<n) { printf("Unesite %d-ti element niza:",i); scanf("%d",&x[i]); i++; } i=0; k=0; while(i<n) { sum[k]=0; while(x[i]) { sum[k]=sum[k]+x[i]-(x[i]/10)*10; x[i]=x[i]/10; } k++; i++; } maks=sum[0]; i=0; while(i<k) { if(maks<sum[i]) maks=x[i]; i++; } printf("Najveci zbir cifara ima element %d",maks); return 0; }