You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j).
EXAMPLE: Input: N = 10000000000, M = 10101, i = 2, j = 6 Output: N = 10001010100
whatever i tried so far-
int main()
{
    int m, n, i, j;
    printf("enter N\n");
    scanf("%d",&n);
    printf("enter M\n");
    scanf("%d",&m);
    printf("enter i\n");
    scanf("%d",&i);
    printf("enter j\n");
    scanf("%d",&j);
    int max = 1;
    int left = max-(( 1 << j)-1);
    int right = ((1 << j)-1);
    int mask = left | right;
    int ret = (n & mask)|(m << 1);
    printf("the answer is %d", ret);
}
but i am getting output-1215753963
 
     
     
     
     
     
    