0

Why is it showing 'time limit exceeded' when i run a program in c?

I made a small program of addition by calling a function in c..but there's no output and its showing 'time limit exceeded'. Why is it so and what's the solution to this? Since I m new , m not getting it.. please help.

12th Jun 2018, 7:06 AM
Riya
4 Answers
+ 3
#include <stdio.h> int sum(int,int); void main() { int s,a,b; a=1; b=5; s=sum(a,b); printf("sum = %d",s); } int sum(int x, int y) { int c; c=x+y; return c; } The above code works fine, now. The problems were: 1. placing function prototype inside the main block. 2. Using obsolete getch() function which belongs to conio.h library (main source of the problem)
12th Jun 2018, 8:02 AM
Babak
Babak - avatar
+ 3
Please attach your problematic code to the post to get more out of your query. That's nearly impossible to tell exactly what is the source of the problem without seeing the actual code.
12th Jun 2018, 7:19 AM
Babak
Babak - avatar
12th Jun 2018, 7:47 AM
Riya
+ 1
oh, got it 😅 Tnk u so much😃😃 C++ Soldier (Babak)
12th Jun 2018, 8:16 AM
Riya