Question:
Assign a=56;how to separate that number(ie:5,6) and multiply(ie:5*6) using bitwise operator?
Answer:
int b,c; b=a/10; c=a%10; cout<<b<<c; a=b*c; cout<<a; Source: CoolInterview.com
Answered by: Rajesh Mohan | Date: 6/18/2008
| Contact Rajesh Mohan
int b,c; b=a/10; c=a%10; cout<<b<<c; a=b*c; cout<<a;
Source: CoolInterview.com
Answered by: amuthapriya | Date: 6/26/2008
| Contact amuthapriya
given a=56 int b,c; b=a&0F; c=a&F0; c=c<<4; cout<<c<<b; cout<<(c*b); Source: CoolInterview.com
Answered by: venkateshappala | Date: 6/30/2008
| Contact venkateshappala
void main() { int value = 56; value = value>>4; value = value<<1; cout<<value<<endl;//display 6 int tmp = value>>2; tmp = value-tmp; cout<<tmp<<endl;//display 5 cout<<tmp*value<<endl; //Multiply 5*6 } Source: CoolInterview.com
Answered by: Arun | Date: 7/2/2008
| Contact Arun
#include <stdio.h> struct int_value{ unsigned int lsb1:4; unsigned int lsb2:4; unsigned int lsb3:4; unsigned int lsb4:4; unsigned int msb1:4; unsigned int msb2:4; unsigned int msb3:4; unsigned int msb4:4; };
int main() { struct int_value value; int a =0x56; int b,c,d; value = *(struct int_value*)&a; b=(int)value.lsb1; c=(int)value.lsb2; printf("%d %d ", b,c); d = b*c; printf("%d", d);
} Source: CoolInterview.com
Answered by: Kanhaiya Lal Yadav | Date: 7/28/2008
| Contact Kanhaiya Lal Yadav
Multiply should be done using bit-wise operators. not using'*' Source: CoolInterview.com
Answered by: Krishna Reddy | Date: 8/7/2008
| Contact Krishna Reddy
#include<stdio.h>
int main() { char a = 0x56; char b = 0x00; char c = 0x00; char d = 0x00; b = a >> 4; c = a << 4; c = c >> 4; printf(" B is %x", b); printf(" C is %x", c); b = b << 1; d = b; b = b << 1; b = b + d; printf(" B is %x %d", b ,b); } Source: CoolInterview.com
Answered by: Nagaraj C L | Date: 8/13/2008
| Contact Nagaraj C L
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|