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
Why c is a procedural language?
Difference between Function to pointer and pointer to function
write a progrmm in c language take user interface generate table using for loop?
program for reversing a selected line word by word when multiple lines are given without using strrev
What is the difference between struct and typedef struct in c?
What are the types of functions in c?
What are the 4 data types?
How many keywords are there in c?
What is the use of static variable in c?
What is the use of void pointer and null pointer in c language?
Is there a way to switch on strings?
What is a structure and why it is used?
code for replace tabs with equivalent number of blanks
How can I get the current date or time of day in a c program?
How do I create a directory? How do I remove a directory (and its contents)?