Question

Labview question: Create a VI using a While Loop that continuously generates random numbers between 0...

Labview question:

Create a VI using a While Loop that continuously generates random numbers between 0 and 1000 until it generates a number that matches a number selected by the user. Determine how many random numbers the VI generated before the matching number.

conditions to applied on above problem:

1. Convert the “random number” generator floating point numerical output to integer values to make it easier to find a match.

2. The “user selected number control” should be on the outside of the loop and be set to an integer representation. The control must also prevent users from entering a value less than zero or greater than 1000.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

open the linux terminal

step1: type vi and Enter

write this code in the vi editor

#include<stdlib.h>
#include<stdio.h>
#include<time.h>
int main(){
   int i=0;
   int count_check=0;
   int check=0;
   srand(time(0));
   int user=1;
   while(1){
   printf("Enter Number");
   scanf("%d",&user);
   if(user>=1 && user<=1000){
       break;
   }
   }
  
   while(check!=user){
       check=rand()%1000+1;
       i=i+1;
}
printf("match number:%d\n",check);
printf("before match:%d",i);
}

after completion after writing enter escape button and type this

: w check.c

the file saved as check.c

later again enter escape button and type

:wq

it was quit from vi editior

later type these commands to execute the code

for compilation of c code

cc -o check check.c

and Enter later

./check

these two commands are used to compile the c code and execute the code.

#if you have any doubts comment below...

Add a comment
Know the answer?
Add Answer to:
Labview question: Create a VI using a While Loop that continuously generates random numbers between 0...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use LabView instead of matlab please Expert Q&A Done Create a VI that: Generates random integers...

    Use LabView instead of matlab please Expert Q&A Done Create a VI that: Generates random integers between 0 and 40. Iterate this random process until the random integer equals 13. Display the following non the Front panel (1.) The actual random number (2.) The iteration number Include a time delay so the user can watch the valuse update as the program executes. USE MATLAB

  • In NI LabVIEW please, Construct a VI that displays a random number between 0 and 1...

    In NI LabVIEW please, Construct a VI that displays a random number between 0 and 1 once every second. Also, compute and display the average of the last four random numbers generated. Display the average only after four numbers have been generated; otherwise display a 0. Each time the random number exceeds 0.5, generate a beep sound using the Beep.vi.

  • Use VI and post output screen Use a For Loop to generate 100 random numbers. Determine...

    Use VI and post output screen Use a For Loop to generate 100 random numbers. Determine the most current maximum and minimum number as the random numbers are being generated. This is sometimes referred to as a "running" maximum and minimum. Display the running maximum and minimum values as well as the current random num- ber on the front panel. P5.2 Be sure to include the Time Delay Express VI so the user is able to watch the values update...

  • A coder programmed a random number generator, which generates a random number between 0 and 1...

    A coder programmed a random number generator, which generates a random number between 0 and 1 when the user presses the "random" button. Numbers generated follow a uniform distribution. 12- What is the probability the next time the button is pressed the code will generate a number less than .23? 13- What is the probability the next time the button is pressed the code will generate a number between .23 and .35? 14- What is the probability the next time...

  • Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive...

    Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...

  • Solve Question using While loops-MATLAB Write a program that generates a random number and asks the...

    Solve Question using While loops-MATLAB Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number.

  • Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program...

    Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...

  • Using the Random, write a simulation that will "play" the California Super LOTTO. Your program logic will allow the player to: 1) Pick any 6 integer numbers from 1 - 70. Your logic should prev...

    Using the Random, write a simulation that will "play" the California Super LOTTO. Your program logic will allow the player to: 1) Pick any 6 integer numbers from 1 - 70. Your logic should prevent the player from selecting a value LESS than 1 or greater than 70. The logic should prevent the player from selecting the SAME number (i.e. they cannot have two or more of their selections be the SAME number). 2) Display the players' 6 number selections...

  • Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through...

    Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through 9 and put this in an array. Then these user numbers are compared to the random numbers the computer generated. The program will display both the computer random number and below the user selected numbers. The program will tell the user how many matches are made. If the user guesses all five you let them know they are the grand winner. Here is the...

  • (C#, Visual Studio) I need help modifying my program code to accommodate repeated numbers. For example,...

    (C#, Visual Studio) I need help modifying my program code to accommodate repeated numbers. For example, if a user inputs a repeated number the program should regenerate or ask to enter again. If needed, here is the program requirements: Create a lottery game application. Generate four random numbers, each between 1 and 10. Allow the user to guess four numbers. Compare each of the user’s guesses to the four random numbers and display a message that includes the user’s guess,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT