URI Problem 1099 – “Sum of Consecutive Odd Numbers II” solution( Bangla ) | C language

**Before watching this make sure that you’ve tried enough**

#include<stdio.h>

int main()
{
    int a, j, b, i, k, n, x = 0;
    scanf("%d", &n);
    int ar[n];
    for(i = 0;i < n;i++){
    scanf("%d %d", &a, &b);
    if (a > b){
        a = a + b;
        b = a - b;
        a = a - b;
    }
    if (a%2 == 0)a--;
    a = a + 2;
    for (j = a;j < b;j=j+2){
            x = x + j;
    }
    ar[i] = x;
    x = 0;
    }
    for(i = 0;i < n;i++){
        printf("%d\n", ar[i]);
    }

    return 0;
}

 

If this solution helped you, please share this with your friends.
And if you have anything to say, let me know in the comment section.
More solutions are coming so Like our Facebook page and Subscribe to our YouTube channel to stay connected.

Leave a Comment