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 are different types of variables in c?

1024


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

1259


write a proram to reverse the string using switch case?

2905


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

1202


How can you convert integers to binary or hexadecimal?

994


Tell us something about keyword 'auto'.

1027


Not all reserved words are written in lowercase. TRUE or FALSE?

1202


Explain about the functions strcat() and strcmp()?

1013


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

992


Where we use clrscr in c?

1109


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1181


What are the disadvantages of a shell structure?

1300


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

1049


What are formal parameters?

1087


Is register a keyword in c?

1013