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 difference between main and void main?

1224


Find MAXIMUM of three distinct integers using a single C statement

1071


How can you avoid including a header more than once?

988


In which language linux is written?

1234


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1006


What is the difference between int main and void main in c?

1182


What are the salient features of c languages?

1101


Write a program for Overriding.

1165


What is oops c?

1258


Do you have any idea about the use of "auto" keyword?

1092


Can we access the array using a pointer in c language?

1053


What is the use of c language in real life?

1029


How is a pointer variable declared?

1102


Difference between Shallow copy and Deep copy?

2032


Why & is used in scanf in c?

1104