CS201 Introduction to Programming GDB Solution 2018

CS201 GDB solution
In my opinion, switch statements id better than If-Else. Switch statements have its best uses then there are more environments. As we know that if statements checks for all the conditions and then when the condition is matched then the following body inside it is executed but this is not the case with switch condition as it directly checks for the compatible conditions and executes the code.
The reason behind the selection of switch statement is;
Working speed of switch statement is much faster than if-else.
The reason is that compiler produces a jump table for a switch in the course of assembling. Thus, during accomplishment, as a substitute of testing which case is contented, it only picks which case has to be accomplished.
It is more understandable and in parallel to if-else testimonials.
Switch statement is more manageable for taking higher level of transactions than if-else

----------------------------------------



Dont Be Confused Keep Keen Attention on Question :) 
This is your gdb solution: 
Switch statement is much faster than if-else due to the following reasons:
Switch statement is better because
1) compiler generates a jump table during compilation.
2) instead of checking which case is true, it only moves to that case which has to be executed.
3) It is more readable.
4) It is more manageable regarding above scenario.


------------------------------------------

I asked Teacher about it and here is her reply:
Dear Student,
First of all, in GDB coding is not required. You have to select a decision structure according to the given scenario and have to provide the reasons. Then login the VULMS, click on GDB icon and post your comments.
Transaction examples are:
a user deposit cash in his/her account.
A user withdraws some cash from his/her account.
A user checks the balance of his/her account etc.
Regards,

Instructor CS201
Department of Computer Sciences
VU, Pakistan

No comments:

Post a Comment