Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS320n – Elements of Visual Programming Assignment Help Session.

Similar presentations


Presentation on theme: "CS320n – Elements of Visual Programming Assignment Help Session."— Presentation transcript:

1 CS320n – Elements of Visual Programming Assignment Help Session

2 Visual ProgrammingAssignment Help Session2 What We Will Do Today Illustrate a few key points on the assignment and work on the assignment

3 Visual ProgrammingAssignment Help Session3 The Assignment Simulate rolling two 6 sided dice Allow user to input number of times to roll –numeric control –this will be input to for loop count terminal inside for loop –need to simulate rolling dice once –need to count up how many times each result occurs –can use an array to do this

4 Visual ProgrammingAssignment Help Session4 Counting Number of Rolls One approach One way of counting number of times each value rolled –store all results in an array –go through array and count number of 2s, then number of 3s, then number of 4s… –A reasonable function would be: how many elements of an array equal some value, but there is no LabVIEW function for this

5 Visual ProgrammingAssignment Help Session5 Mapping Another approach A useful technique in programming instead of using an array to hold the results of the roll, use an array to count the number of times each roll occurs the index of the array is used to map to the result of a roll

6 Visual ProgrammingAssignment Help Session6 Sample Array Index 01234567 Element 0013781240 use result of roll as index into array element indicates how many time that roll has occurred. 1 two, 3 threes, 7 fours… Assume the next roll is a 4. How does array change?

7 Visual ProgrammingAssignment Help Session7 Result is 4 Index 01234567 Element 0013881240 Element at index 4 incremented by 1. Was 7, now is 8.

8 Visual ProgrammingAssignment Help Session8 Using Mapping To use mapping auto indexing is not useful when rolling the dice and counting the results Need to use a shift register to pass whole array between iterations of the loop need to use the Index Array to get old value of element, increment it (add 1), and then use the Replace Array Subset function to update the element


Download ppt "CS320n – Elements of Visual Programming Assignment Help Session."

Similar presentations


Ads by Google