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
Explain what does a function declared as pascal do differently?
Can we initialize extern variable 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
c language interview questions & answer
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is a sequential access file?
How do you write a program which produces its own source code as output?
What are the different types of endless loops?
How many data structures are there in c?
What is the use of getch ()?
How many levels deep can include files be nested?
What are the 4 data types?
Write a program to print numbers from 1 to 100 without using loop in c?
When should the const modifier be used?
write a program to print largest number of each row of a 2D array