Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


The Graded Discussion Board (GDB) for CS201 will be held on 11th and 12th of August 2016. The topic of the GDB is:

Suppose that you have to write a small C/C++ program where the fast execution of the program is the key requirement. The memory utilization by the program is not an issue at all. You are given two options to develop the program either using Inline functions or simple ordinary functions.

Which of these options you will choose to develop the program? Justify your answer with solid reason(s). 

NOTE:

Keep your answer to the point.

Your answer should not exceed 3 to 4 lines.

Plzzzz discuss 

Views: 1319

Replies to This Discussion

i dont take it negative.I agree you. Next time write in my own words.Thank you for your justification.

Thanks, yes we should work hard to learn.. 

Thank u so much

Thanks, I think I got the point and I will try to learn more points to justify my answer. :)

Please Discuss here about this GDB.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

Inline functions should be my choice because it is provided that the fast execution of the program is the key requirement and the memory utilization by the program is not an issue at all. Other reasons to use Inline functions are as under:-
1. It avoid function calling overhead.
2. Variables pop on the stack and overhead is avoided during function call.
3. No return call from a function to other function which is again an overhead.
4. No linker complaining happen when include at mutiple places.

cs201 GDB Solution ...

Attachments:

Cs201_GDB_Solution

Answer:

"Inline functions should be your choice because.1.It avoid function calling overhead.2. variables pop on the stack overhead is avoided during function call3. No return call from a function to other function which is again an overhead4.No linker complaining happen when include at mutiple places."
Below is argument why normal functions are not choice .
For normal function call the program stores member address of instructions when u call a function. It loads the function into the memory then copies parameter values and jumps to the memory location of function you r calling.Now it run the function codes and stores the function return valu, and then jump back to the location from where function was invoked.

Cs 201 (Introduction to programming) GDB#1
Total marks: 03
Question no 1:
Suppose that you have to write a small C/C++ program where the fast execution of the program is the key requirement. The memory utilization by the program is not an issue at all. You are given two options to develop the program either using Inline functions or simple ordinary functions.
Which of these options you will choose to develop the program? Justify your answer with solid reason(s).

Answer:
In C++/C language while writing a small program we use line function.
This function is definite or actual. During the compilation line functions which are easily copied everywhere. Inline functions do increase competence, but we should not make all the functions inline. Inline function is commonly used with classis because it is very powerful.
Inline function should be our choice because of its some function like,
When line function include in multiple places, no linker compiling happens.
It is advised to define large functions outside the class definition using scope resolution operator, because if we define such functions inside class definition, then they become inline automatically.
It avoids function calling overhead.
No return calls from a function to other function which is again an overhead.
Variable push on the stack overhead is avoided during function call.

Asslam-u-Alaikum,

Correction, Inline function was introduced in C++ only, C doesn't has this facility this was also a trick in the question.

Now since the memory and hdd space is not an issue at all, the choice must be inline function, reason behind is the robust operation during execution, How it works? simply when we declare any function with prefix of inline compiler in actual write the code of that function where is called in main or any where else in the program, so for example if you call the cost 10 places in the program it will create 10 copies of this code in the whole program.

on the other hand normal function can be called by values or by reference and during execution time reference will always look towards function in order to produce desired results, eventually will effect the execution.

Here one must consider not using inline function in big programs, since compiler is creating the copies of code line into places where it has been called it the complied file size will be increased, therefore professional program avoid using inline function while coding for embedded devices due to limitation of memory. moreover compiler also play a vital role in the decision of using inline function, compiler also decide whether to use inline or keep it as normal function, how can one check this? obviously need to debug which is a tedious job for juniors like us.........

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service