+ 1

What should be the output of the program and why??

https://code.sololearn.com/c8KRO0BUThlD/?ref=app

27th Nov 2019, 1:04 PM
Prakhar
3 Antworten
+ 2
You have specified your function as void fun(). This means, it doesn't take an argument. In main, you write fun(fun());, so you are giving an argument. Just write fun(); and it will work.
27th Nov 2019, 1:07 PM
HonFu
HonFu - avatar
+ 2
If the fun() argument would just evaporate, that might be the case, but it doesn't seem to work like that. It is just checked (I don't know how exactly) that you pass something (a void expression) although you shouldn't. Personally, I wouldn't even look further into it. 'Ah, I passed something although I shouldn't - silly me.' If you want a deeper interpretation... hm... I hope someone else can provide it. ;-)
27th Nov 2019, 1:28 PM
HonFu
HonFu - avatar
0
But the written type of fun is void so it does not return anything. So in fun(fun()), as inside fun() will get executed, it will return nothing. So fun(fun()) should be same as two times fun() ;
27th Nov 2019, 1:14 PM
Prakhar