Use of void main()

here when we use void main it shows compile time error, and when we use int main then we return hi hi.

the correct answer to this question is given is hi hi.(using void main only).

so what is the correct answer? 

1Comment
Shraddha @shraddhagami
29 Jan 2017 12:25 pm

@sonali

Hi hi is correct answer

It doesn't return anything so no need of int main()

Static variables memory allocation is done at compile time

So x is increment by 1 so, x=4 

And if condition is true so it will print hi and then call main function again

So when main function execute 2 nd time value of x is increment by one so now value of x=5 and if condition is true again and then again call main function

When main function execute 3 rd time and value of x becomes 6 so if condition is false.

  

Pages