write a program for 7*8 = 56 ? without using * multiply
operator ? output = 56
Answer Posted / pavan_mustyala
Method1:
optimised code is to "left shift" the number 7 by 3 times.
Reason: 8 is (2 raised to power 3). So (7 * 8) is
equivalent to (((7*2)*2)*2). To multiply a number by 2,
shift it by 1 bit Left.
Method2:
Not optimised but it works. Addition in a loop.
int func()
{
int i;
int result = 0;
for(i = 0; i < 8; i++)
{
result = result + 7;
}
return result;
}
| Is This Answer Correct ? | 14 Yes | 4 No |
Post New Answer View All Answers
What is typedef struct in c?
What is the purpose of sprintf() function?
How many types of arrays are there in c?
What is the concatenation operator?
Can we declare variable anywhere in c?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
Explain what happens if you free a pointer twice?
What is difference between union and structure in c?
What is the purpose of the preprocessor directive error?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
How many keywords are there in c?
Explain what is the best way to comment out a section of code that contains comments?
Why is it important to memset a variable, immediately after allocating memory to it ?
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
What does c mean in standard form?