So I have declared an integer called toplam in c but did not give it a value at all. However when I opened the watches window it is shown that it has a value of 16. I used an online c compiler and copy and pasted the code into it and it ran smoothly without assigning any value to toplam unless asked. I think this is an error in Codeblocks itself but i am not sure. how do I fix this without having to subtract 16 from toplam in order for it to be 0?
int fak(int j){
int sonuc=1;
while(j!=0){
sonuc = sonuc * j;
j--;
}
return sonuc;
}
int main()
{
int sayi,i,j,sonuc,toplam;
printf("sayi giriniz: \n");
scanf("%d",&sayi);
for(i=1;;i*=10){
if(sayi/i==0){
break;
}
j=(sayi/i)%10;
printf("%d\n",j);
toplam=toplam+fak(j);
}
printf("%d",toplam);
return 0;
}
this is my code. It takes the inputed number and prints out the individual numbers in it and then adds their faktorials together.