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
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
If the size of int data type is two bytes, what is the range of signed int data type?
What is p in text message?
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is boolean in c?
How can you determine the size of an allocated portion of memory?
What is the use of header?
Write the Program to reverse a string using pointers.
Can a pointer be static?
Write a program to swap two numbers without using third variable?
What is strcpy() function?
What is a char in c?
what are bit fields in c?
What do the functions atoi(), itoa() and gcvt() do?
How will you write a code for accessing the length of an array without assigning it to another variable?