+ 2
Why this simple code is not running? It shows time limit exceeded as output.
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int i,n,s,ss,sss; printf("\n enter the value of n="); scanf("%d",&n); s=0; ss=0; sss=0; for(i=1;i<=n;i++) { s+=i; ss+=i*i; sss+=i*i*i; } printf("\n sum of numbers=%d",s); printf("\n sum of squares=%d",ss); printf("\n sum of cubes=%d",sss); getch(); } https://code.sololearn.com/c3ndxKRE77ar/?ref=app https://code.sololearn.com/c3ndxKRE77ar/?ref=app
3 RĂ©ponses
+ 1
main method must return int. And your code doesn't need conio.h and math.h. Remove them and getch(),
0
Thanks for helping. My code run successfully, but this was runned on turbo c and not in this app.