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...

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


Please Help Members By Posting Answers For Below Questions

What is the difference between text and binary modes?

1239


What is far pointer in c?

1388


write a c program to find the sum of five entered numbers using an array named number

2203


How many keywords are there in c?

1123


Why is it important to memset a variable, immediately after allocating memory to it ?

2131


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

2018


please send me the code for multiplying sparse matrix using c

2222


How is a macro different from a function?

1243


How do I get an accurate error status return from system on ms-dos?

1175


Can a void pointer point to a function?

1076


How arrays can be passed to a user defined function

1069


What is the explanation for modular programming?

1269


Explain zero based addressing.

1096


write a c program to calculate sum of digits till it reduces to a single digit using recursion

3380


What happens if header file is included twice?

1211