ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

why wrong answer on test case #2 ?
Posted by Al - Amin Hosen 9 Nov 2018 08:18
#include<stdio.h>
int main()
{
    int n, sum=0, i;

    scanf("%d", &n);
    if(n>0)
    {
        for(i=1; i<=n; i++)
            sum=sum+i;
    }
    else if(n<0)
    {
        for(i=n; i<=1; i++)
            sum=sum+i;
    }
    printf("%d", sum);

    return 0;
}
Re: why wrong answer on test case #2 ?
Posted by decay 9 Nov 2018 15:02
What if N = 0?
Re: why wrong answer on test case #2 ?
Posted by Al - Amin Hosen 11 Nov 2018 23:56
thank you sir.