.... How to Find Your Subject Study Group & Join ....   .... Find Your Subject Study Group & Join ....  

We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Study Groups By Subject code Wise (Click Below on your university link & Join Your Subject Group)

[ + VU Study Groups Subject Code Wise ]  [ + COMSATS Virtual Campus Study Groups Subject Code Wise ]

Looking For Something at vustudents.ning.com?Search Here

Decision Structures
Question Description

Suppose you are required to write a C/C++ program for a bank in which all transactions of a day will be compared. Keep in mind a huge volume of transactions per day:

Your code should have following features:

  • The processing speed must be high.
  • The logic of the program must be simple.

Which decision structure (if-else and switch statement) would you choose to achieve above mentioned features of code, and also mention reasons in favor of your choice.

[Note: Answer must be comprehensive with logical reasoning. Confine your answer within 3 to 5 lines]

Share This With Friends......


How to Find Your Subject Study Group & Join.

Find Your Subject Study Group & Join.

+ Click Here To Join also Our facebook study Group.


This Content Originally Published by a member of VU Students.

+ Prohibited Content On Site + Report a violation + Report an Issue


Views: 5455

See Your Saved Posts Timeline

Replies to This Discussion

m also confused about that what type of transaction would be compared 

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

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.

Regards (Sir G)

agreed

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

GDB ki zara samj ni a rahi koi help kar day.

dear koi to solution file bhej do aj last date he..

if else or switch

confirm batao

CS201 GDB Solution 

Solved GDB CS201 

According to features of the c/c++ language, switch statement is much faster than simple if-else statement. We know that switch statement uses the cases for switching. So it is more compact for the compiler, so it generate the jump table. This jump table is fix not change. It is also called multiway branch or branch table. So in my opinion switch is the best choice in this scenario. Because of speed, compactness and cases. Switch statement allow the value of a variable or expression to change the control flow of program execution via a multiway branch.

RSS

Forum Categorizes

Job's & Careers (Latest Jobs)

Admissions (Latest Admissons)

Scholarship (Latest Scholarships)

Internship (Latest Internships)

VU Study

Other Universities/Colleges/Schools Help

    ::::::::::: More Categorizes :::::::::::

Member of The Month

1. +ɹǝʞɔɐɥ

Punjab, Pakistan

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

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