Give 2 examples of a code optimization?
Answers were Sorted based on User's Feedback
Answer / mms zubeir
I would like to quote two things from the same area.
1. Read/Write chunks from/into a file instead of byte by
byte reading.
2. Aquire resources late and relieve it early. Example, if
you want to use a file, open the file as late as possible
and release it as early as possible after use.
Is This Answer Correct ? | 12 Yes | 1 No |
Answer / 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 |
Answer / sudheer
How this num1&(num2-1) replaces num1%num2. Execute and
check before posting some thing...
Is This Answer Correct ? | 1 Yes | 4 No |
3- Write a program to find larger and smaller of the two numbers.
Can I make ios apps with c++?
What are the differences between a struct in C and in C++?
What is the difference between new/delete and malloc/free?
What are pointer-to-members? Explain.
Difference between shift left and shift right?
What is an ABC: an "Abstract Base Class"?
Is c++ faster than c?
Who invented turbo c++?
How new/delete differs from malloc()/free?
Is c++ built on c?
What does the nocreate and noreplace flag ensure when they are used for opening a file?