Fibbonaci series

Why in fibbonaci series we have to write print statement before sum intialisation (sum=a+b) ? Why not in the end and also they are giving different answer?

no,it is not compulsory to print before sum.you just need to take care of first 2 numbers. you can see this: