|
|
back to boardDiscussion of Problem 1068. SumWhat is test 2 and what is wrong with my code? C programming language Posted by creaky 12 Oct 2012 16:23 #include<stdio.h> main() { int a, sum=0; scanf("%d",&a); if(a<0&&a>=-10000) { int i; for(i=a;i<=1;i++) { sum=sum +i;
} printf("%d",sum); } else if( a>=0&&a<=10000) { int i; for(i=1;i<=a;i++) { sum=sum +i; } printf("%d",sum);
} }
Re: What is test 2 and what is wrong with my code? C programming language when a = 0, the answer is 1, not 0 Edited by author 12.10.2012 23:50 Re: What is test 2 and what is wrong with my code? C programming language Posted by creaky 16 Oct 2012 16:06 I have executed the program and when I input 0 the result is also 0. But still they are not accepted |
|
|