LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Exercise Problems

exercise#2:Flipping coin

0 Kudos
Message 11 of 13
(922 Views)

 

Hey there,

 

Welcome to LabVIEW! It’s totally normal to face some challenges in the beginning, but you’re on the right path by working through example problems. I’d be happy to help you out.

 

Exercise #1:
To solve this, you can use a For Loop that runs from 1 to n. Inside the loop, multiply the loop index by 2 to get the even numbers (2, 4, 6…2n), and add them up using a shift register. Before running the loop, make sure the input number n is a positive integer. You can use a Greater Than comparison to check that n > 0. If it's not, show a message to the user saying the input is invalid.

 

Exercise #2:
You can use a For Loop to repeat the coin flip 100 times. Inside the loop, use the Random Number function (0 to 1 range). If the number is > 0.5, count it as a Head; if it's ≤ 0.5, count it as a Tail. Again, use shift registers to keep track of the count for heads and tails. When the loop finishes, display both results.

 

If you ever want to get a feel for the concept without coding right away, you can even try to flip a coin online to understand the randomness.

 

Keep practicing and don’t hesitate to ask more questions—everyone starts somewhere!

Download All
0 Kudos
Message 12 of 13
(268 Views)

I'm pretty sure their course has ended, 5 years later, bot.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 13 of 13
(238 Views)