Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why c is a procedural language?

1068


Difference between Function to pointer and pointer to function

1089


write a progrmm in c language take user interface generate table using for loop?

2052


program for reversing a selected line word by word when multiple lines are given without using strrev

2482


What is the difference between struct and typedef struct in c?

1128


What are the types of functions in c?

990


What are the 4 data types?

1023


How many keywords are there in c?

1080


What is the use of static variable in c?

1092


What is the use of void pointer and null pointer in c language?

1127


Is there a way to switch on strings?

1090


What is a structure and why it is used?

1229


code for replace tabs with equivalent number of blanks

2167


How can I get the current date or time of day in a c program?

1227


How do I create a directory? How do I remove a directory (and its contents)?

1174