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 |
Can notepad ++ run c++?
Show the application of a dynamic array with the help of an example.
What do you mean by function and operator overloading in c++?
What is string in c++ programming?
Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?
What is the output of the following 3D Array int arr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12}; what is the output for arr[2][1][0]?
6 Answers HCL, Integra, IPMC, ORG,
How does c++ sort work?
What is null and void pointer?
Given the following function definition: int doit(int &x, int y, int &z) { x = 3*x; y = y + 5; z = x+y; return z - 4; } int a = 5, b = 7, c = 9, d = 11; d = doit(a,b,c);
What is linked list in c++?
Where Malloc(), Calloc(), and realloc() does get memory?
What is the difference between c++ and turbo c++?