Wednesday, April 13, 2016

UVA Problem 10783: Odd Sum -Solution

Unknown
#include <stdio.h>
int main()
{
    int t, n=1, a, b,i,sum;
    scanf("%d",&t);
    while (n<=t)
    {
        scanf("%d",&a);
        scanf("%d",&b);
        sum=0;
        for (i=a;i<=b;i++)
            if (i%2==1) sum+=i;
        printf("Case %d: %d\n",n++,sum);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,