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

Time limit exceeded

I made a calculator program in C, but it said time limit exceeded when running it. Please help me to increase the time limit

6th Jul 2018, 5:02 PM
Ankit Kumar
Ankit Kumar - avatar
12 Answers
+ 4
More than likely your time usage is due to a bug. If you link your code here, we might find it so your program works.
6th Jul 2018, 5:53 PM
John Wells
John Wells - avatar
+ 5
you cannot increase the time limit. sololearn sends the code to their server,its run there and output is returned back to codeplayground. this means your code has a limited runtime
6th Jul 2018, 5:50 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 5
getch is what is causing your issue. It is a non-standard function so is hanging your program. Use the standard equivalent: getchar. To enter in Playground, run with: 5 6*
6th Jul 2018, 7:05 PM
John Wells
John Wells - avatar
+ 3
Harsh I have rectified your all errors and made it working here.Input pattern is changed as it was the bug,so check the C-comments section inside the program for more details .Program logic remains same.No change to your program logic.Check the link given far below to the program for further details. The program explains in details for each step reporting errors and the correction made against it in form of C-comments. Run the program and execute it to get the output. The main cause or bug of your program not working here is precedence order to read input from user. Check the program below for detailed explanation and a suggestion from my side would be read the C-comments in code section of the program along with C-Comment section for detail understanding. Hope it clarifies your doubt. The link to the program is given below here, feel free to look:- https://code.sololearn.com/cxC13o2OL6r7/?ref=app
7th Jul 2018, 9:07 PM
D-Key
D-Key - avatar
+ 2
One of the reason can be program goes in an infinte loop.
6th Jul 2018, 6:26 PM
Mitali
Mitali - avatar
+ 2
my program runs in android dosbox
6th Jul 2018, 6:34 PM
Ankit Kumar
Ankit Kumar - avatar
+ 2
Thank you
6th Jul 2018, 7:24 PM
Ankit Kumar
Ankit Kumar - avatar
6th Jul 2018, 6:44 PM
Ankit Kumar
Ankit Kumar - avatar
+ 1
https://code.sololearn.com/cX04BG4Uio56/?ref=app
6th Jul 2018, 7:24 PM
Ankit Kumar
Ankit Kumar - avatar
0
Usually this happens is because of an infinite loop. It takes a lot for a normal program to take 5 seconds to compile and run
6th Jul 2018, 6:28 PM
ReimarPB
ReimarPB - avatar
0
I'd have stuck with scanf()... More importantly, you need to handle if x is not +, -, /, or *. Most would suggest a case default, but may I suggest a while statement, eg: char x = 0; ... while (x != '-' && x != '+' && x != '*' && x != '/') scanf("%c", &x); /* or x = getchar() if you prefer */ Just makes life easier to avoid invalid input. Although you should usually have a default case. You also need to format your code or you'll lose track of it. It's not very legible. Anyway, good luck!
6th Jul 2018, 11:49 PM
non
0
I made a program for pattern and it is not running and say time exceeded
20th Jun 2019, 3:58 AM
Kumar Bikash
Kumar Bikash - avatar