CopyBits(x,p,n,y)
copy n LSBs from y to x starting LSB at 'p'th position.
Answer Posted / vadivel t
Hi,
The below code ll giv desired o/p.
#include<stdio.h>
#include<conio.h>
int main()
{
int x, y, n , p, i, j, temp;
printf("ENTER X, Y, NO OF BITS AND BIT POSITION: \n");
scanf("%d %d %d %d",&x, &y, &n, &p);
for(i = p, j = 0; i < n+p; i++, j++)
{
if(x & (0x01 << i))
x = x^(0x01<<i);
temp = y & (0x01<<j) ? 1 : 0;
x = x | (temp << i-1);
}
printf("VALUE OF X:%d \n",x);
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Who invented bcpl language?
What are near, far and huge pointers?
What is the use of bitwise operator?
What does c value mean?
Is struct oop?
What is pivot in c?
What are the differences between Structures and Arrays?
List a few unconditional control statement in c.
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Describe static function with its usage?
There seem to be a few missing operators ..
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
What is the easiest sorting method to use?
How can I ensure that integer arithmetic doesnt overflow?
Why isn't it being handled properly?