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

Give 2 examples of a code optimization?

Answer Posted / maria

1) For checking modulo use

num1&(num2-1)

instead:

num1%num2

2) For multiplying or dividing by 2 use left and right shift
accordingly.

3) In loop use, if code allows it, decrement,like this:
for(int i = MAX_VALUE ; i > 0 ; i--)
instead:
for(int i = 0 ; i < MAX_VALUE; i++)

Is This Answer Correct ?    7 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe private, protected and public – the differences and give examples.

1259


What you know about structures in C++?

1141


Explain the concept of memory leak?

1156


What does flush do c++?

1120


What is protected inheritance?

1096


What is a breakpoint?

1075


Is it possible for a member function to delete the pointer, named this?

1240


What is purpose of abstract class?

1127


What is ctime c++?

1172


Eplain extern keyword?

1082


Do you know the use of vtable?

1186


Why do we need runtime polymorphism in c++?

1071


What is cin clear () in c++?

1321


Explain terminate() and unexpected() function?

1162


Explain bubble sorting.

1142