printing number from array question..
i got this 50 cell integer array
i use only a few cells from 0(which represents the highest coefficient of 10^(col-1) )
to cell col-1 (which coefficient is 10^0 =1)
i got an input in this array
i could have the number 123 in cell col-1
so i need to add in cell col-1 the number 3
int cell col-2 (tens) i need to add 2
and in cell col-3 (the hundreds) i need to add 1
the problem is that in some cell there could be such a big number
that i would need to change the variable col.
and i couldnt do this simple process that i described in the beginning
i tried to build this :
Code:
kounter=0;
for (index=0;index<cols;index++){
sumc[index]=0;
}
for(index=cols-1;index>=cols;index--)
{
copy=sumc[index+kounter];
while (copy!=0){
sumc[index+kounter]=sumc[index+kounter]+copy%10;
copy=copy/10;
kounter--;
}
}
for (index = 0; index < rows; index++)
{
printf("%d",sumc[kndex]);
}