[Solved] Why I am getting wrong output 2686924 instead of 281?


There are many statements in your code that literally DO NOTHING,

7+8+14;
a+a2;
b+b2;
c+c2;
d+d2;
e+e2;
f+f2;

and

answer=answer;

You see, answer is uninitialized. You never set it’s value in the code, so you need something like

// Initialize `answer' here
answer = 7 + 8 + 14;
answer = answer + a + a2;
answer = answer + b + b2;
answer = answer + c + c2;
answer = answer + d + d2;
answer = answer + e + e2;
answer = answer + f + f2;

Also,doyouunderstandthislineoftext? You can’t without spaces right! Well the same goes for the code.

7

solved Why I am getting wrong output 2686924 instead of 281?