Back to General discussions forum
Hi! i am using C. This is my source code
i've already test it in VScode and run very smoothly but Codeabbey compiler gave me a different output.
int main(int argc, char const *argv[])
{
int a,x,y,z;
int n;
int i;
int result;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d %d %d",&x,&y,&z);
a = x*y+z;
while(a != 0)
{
result += a % 10;
a /= 10;
}
printf("%d \n", result);
}
return 0;
}
Can u guys notice where's my mistake??
You have done very simple but frequent mistake! You used unisialized variable result
.
Okayy! Solved. Thank you guys for your help. I am sorry for an idiot question.