Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. Generate 50 random numbers between the numbers 100 and 300. Pick a number at

ID: 3747560 • Letter: 6

Question

6.

Generate 50 random numbers between the numbers 100 and 300. Pick a number at random out of these 50 random variables.

Determine the probability of the chosen number being greater than 200. This may be achieved by counting the numbers that are greater than 200 and dividing the count by 50. Make sure you,

Formulate the appropriate if-conditions to check for a number being greater than 200

Use a for-loop to apply the if-condition for all 50 numbers

Determine the probability of the chosen number being greater than or equal to 150

and less than 250?

Display the output using the serial monitor.

Arduino problem! Please solve neatly and show all steps. I will give thumbs up for the correct answer! Thank you in advance!

Explanation / Answer

#include <stdio.h>

int main()
{
int arr[50];
int prob1=0;
int prob2=0;
int i;
for (int i=0; i<50; i++)
{
arr[i]= (rand() %201) + 100; /* formula to generate random numbers in range is => num = (rand() % (upper – lower + 1)) + lower

*/
printf("%d ", arr[i]); /*generating random numbers now */
if (arr[i]> 200)
prob1=prob1+arr[i];

if (150 <= arr[i] < 250)
prob2= prob2+arr[i];
}
  
/* checking the probability now */
printf("the probability of the chosen number being greater than 200 is ");
prob1 = prob1/50;
printf("%d ", prob1);
  
printf(" the probability of the chosen number that is greater than or equal to 150 and less than 250 is ");
prob2 = prob2/50;
printf("%d ", prob2);
  
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote