Problem 11 run very well in my vscode but Codeabbey compiler gave me a different output

Back to General discussions forum

Adnoneee     2020-11-30 10:32:48

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??

Quandray     2020-11-30 14:31:13
User avatar

You say it "run very smoothly" in VScode, but what happens if you run it with the example input data?

This is what I see! Which is nothing like the expected output.

Alexandr Milovantsev     2020-11-30 15:04:04

You have done very simple but frequent mistake! You used unisialized variable result.

Adnoneee     2020-12-01 02:17:25

Okayy! Solved. Thank you guys for your help. I am sorry for an idiot question.

Please login and solve 5 problems to be able to post at forum