|
|
back to boardDiscussion of Problem 1068. Sumwhat is wrong with this code it is giving correct output Posted by garra 18 Jan 2012 08:42 #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int s,i,sum=0; scanf("%d",&s); if(abs(s)<10000) { if(s>0) { for(i=1;i<=s;i++) { sum=sum+i; } printf("%ld",sum); } else { for(i=1;i>=s;i--) { sum=sum+i; } printf("%ld",sum); } } return 0; } |
|
|