Pascal triangle https://ide.codingblocks.com/s/139093

I am getting correct output in other compiler but when I am executing this, I am not getting correct output

Hello @ashutoshu,

Your code is logically incorrect. Please, try to correct it.
Let me know if you face any issue.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

then why my cod is executed in other compiler
if it is wrong?

@ashutoshu,

Please, share the screen shot of that.
As when i executed it, it was giving wrong output.

see i have executed this same code in sublime test as i have attatched above

Sure @ashutoshu,

I’ll check it again.
Can you share the link of your code.
The previously shared link contains some other code.

this is link of code,but this code is not running in coding block online compiler but in others like sublime,geeksforgeeks i am getting correct outputs.

Hello @ashutoshu,

There is an error in your code that is causing wrong answers:
Your fact() function is not returning n.

I have modified your code:

Then why is it giving correct output in other compilers? Why?

As there is a missing return statement inside the function, so its result is undefined behaviour.
The result of the function will depend on the compiler you are using.
In common implementation, the return value will be what code has left in the processor’s accumulator register.
This was the case with G4G and others giving the correct output.

Hope, this would help.
Give a like if you are satisfied.

2 Likes

yeah i got it…its very silly mistake i was committing but unable to trace it…thannk you

@ashutoshu anytime,

Please, mark this doubt as resolved.
BTW, i won’t mind a like. You can click that heart is you appreciate the efforts.

1 Like