Time limit exceeded in calling main function. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Time limit exceeded in calling main function.

Can anyone say what is wrong in this https://code.sololearn.com/cDV8MObLBF36/?ref=app

7th Jul 2018, 6:19 PM
Ankit Kumar
Ankit Kumar - avatar
8 Answers
+ 4
Harsh because of how post-increment works, if you put i++ in the condition, main will be called and "i" will never actually increase
7th Jul 2018, 7:13 PM
hinanawi
hinanawi - avatar
+ 3
line 15 never gets executed and they create something like infinite loop It should work correctly if you remove line 15 and change line 13 to if(i++==1)
7th Jul 2018, 6:35 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
but why i++ never get executed
7th Jul 2018, 6:42 PM
Ankit Kumar
Ankit Kumar - avatar
+ 3
because(i think) main function never finishes
7th Jul 2018, 6:45 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
:-O
7th Jul 2018, 6:45 PM
Ankit Kumar
Ankit Kumar - avatar
+ 2
oh yes! you are absolutely correct. When main is called, the controller move to main() and i++ does not get executed. Thank you
7th Jul 2018, 7:15 PM
Ankit Kumar
Ankit Kumar - avatar
+ 1
Mert now check my program, I had put i++ above and it worked. How??? and why not before??? https://code.sololearn.com/cDV8MObLBF36/?ref=app
7th Jul 2018, 6:48 PM
Ankit Kumar
Ankit Kumar - avatar
0
Agent I want to call main from function.
7th Jul 2018, 6:53 PM
Ankit Kumar
Ankit Kumar - avatar