1: main()
2: {
3: int num1 = 0xffffffff;
4: int num2 = 0x12345678,c = 0;
5: int p1=0,p2=0;
6: int mask = 0;
7: // Enter the overlapping bits position
8: printf("Enter first overlapping bit position:");
9: scanf("%d",&p1);
10: printf("Enter second overlapping bit position:");
11: scanf("%d",&p2);
12: mask |= (1 << p1-1);
13: mask |= (1 << p2-1);
14: c = num2 & mask;
15: num1 |= c;
16: printf("After overlapping = %d\n",num1);
17: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Sunday, October 5, 2014
WAP to overlap the bits from one number to another given number if the overlapping bit position is given
Labels:
C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment