Friday, 18 March 2016

Solution of URI 1133 :: Rest of a Division


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d", &a, &b);
    if(a<b)
    {
        for(c=a+1; c<b; c++)
        {
            if(c%5==2 || c%5==3)
                printf("%d\n",c);
        }
    }
    else if(a>b)
    {
        for(c=b+1; c<a; c++)
        {
            if(c%5==2 || c%5==3)
                printf("%d\n",c);
        }
    }
    return 0;
}

4 comments:

  1. can u pls tell me why we added a+1 why not a;a<b;a++

    ReplyDelete
    Replies
    1. I would like to know as well

      Delete
    2. because it says between x&y, not including x&y

      Delete
    3. Thanks for the answer. Makes sense

      Delete

Note: only a member of this blog may post a comment.