CopyBits(x,p,n,y)
copy n LSBs from y to x starting LSB at 'p'th position.
Answer Posted / vadivel t
Hi,
Small bug is there in the above code, which i have posted.
But the same has been resolved here.
#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-1))
x = x^(0x01 << i-1);
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
Can we change the value of #define in c?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
Write a code on reverse string and its complexity.
What is the size of array float a(10)?
Which driver is a pure java driver
what are bit fields in c?
Where is c used?
What is double pointer?
Is c++ based on c?
What are the advantages of using new operator as compared to the function malloc ()?
What is data structure in c programming?
What is pointer to pointer in c language?
What are static variables in c?
What is selection sort in c?
Explain what is a stream?