Question

In C programming Propose an algorithm to generate random numbers and store each value as an...

In C programming

Propose an algorithm to generate random numbers and store each value as an entry in an array.

Homework Answers

Answer #1

Algorithm:

==========

int arr[50];
srand(time(0));
for(int i = 0; i<50; i++)
arr[i]=rand()%10;

for(int i=0;i<50;i++)
display arr[i]

end of algorithm

===================

#include <stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
int arr[50];
srand(time(0));
for(int i = 0; i<50; i++)
arr[i]=rand()%10;

for(int i=0;i<50;i++)
printf("%d ",arr[i]);
return 0;
}

DON'T FORGET TO HIT LIKE.

THANKS BY HEART.

COMMENT DOWN IF ANY PROBLEM.

Know the answer?
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
Similar Questions
Show how to use Metropolis Algorithm to generate a random variable with an approximate student’s t...
Show how to use Metropolis Algorithm to generate a random variable with an approximate student’s t distribution with v degrees of freedom, starting from N(0,1) random variables. (Not using programming codes)
How do I generate random numbers? What's the best way to generate random numbers?
How do I generate random numbers? What's the best way to generate random numbers?
1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array...
1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array to a temp array 3.) Call each of the methods to sort (bubble, selection, insertion, quick, merge), passing it the array 4.) In-between the calls, you are going to refresh the array to the original numbers. 5.) Inside of each sorting method, you are going to obtain the nanoseconds time, before and after the method Subtract the before time from the after time to...
In this programming exercise you will create an algorithm for solving the following version of the...
In this programming exercise you will create an algorithm for solving the following version of the m Smallest Numbers problem.   Instead of just returning the m smallest values as in homework 1, you want to return a list of the positions where the m smallest values are located without changing the original array. Your algorithm should meet the following specifications: mSmallest( L[1..n], m ) Pre: L is a list of distinct integer values. n is the number of elements in...
JAVA PROGRAMMING Declare an array variable (not a populated array, numbers only) for each of the...
JAVA PROGRAMMING Declare an array variable (not a populated array, numbers only) for each of the following situations. 10 Student’s first names 5 Student’s first and last names 5 Student’s last names and 10 assignment names that can be either essays or labs, not both.
Random number generator 1: Search for algorithms generating pseudo-random numbers. Select one of them for generating...
Random number generator 1: Search for algorithms generating pseudo-random numbers. Select one of them for generating a pseudo-random sequence. Original sample can be generated in any form: binary, decimal, etc. But submitted sample must be in the form of uniform random numbers on [0,1][0,1]. The sample should not be generated by any function, like runif(), sample(), etc. Instead it must be some algorithm that you code yourselves. For example, mid-square algorithm, Fibonacci-based algorithm, etc. Random number generator 2: Find some...
Generate 1000 random numbers from Normal (mean=25, sd=3) and store in a vector. How many of...
Generate 1000 random numbers from Normal (mean=25, sd=3) and store in a vector. How many of these data points are greater than 26? (You can directly use built in functions in R or use conditional/unconditional iterations). Please provide your final R code and the output.
Generate 1000 random numbers between 0 and 1*Create a frequency table with the following Generate 1000...
Generate 1000 random numbers between 0 and 1*Create a frequency table with the following Generate 1000 random numbers between 0 and 1*Create a frequency table with the following bins 0, 0,1, 0.2, ..., 0.8, 0.9 , 1Find the expected value bins 0, 0,1, 0.2, ..., 0.8, 0.9 , 1Find the expected value
using any programming language (typed so i can read) Generate a random sequence of length N...
using any programming language (typed so i can read) Generate a random sequence of length N = 500 from a uniform distribution. Using histograms with bin numbers M = 5, 7, 9, 11 and 13 bins, verify experimentally that the error in computed entropy e = Htheoretical – Hobserved varies linearly with the ratio (M – 1) / (2N).
Give an algorithm to generate random variates from the following probability density function. f(x) = 2x/3...
Give an algorithm to generate random variates from the following probability density function. f(x) = 2x/3 if 0<=x<=1 =1-x/3 if 1<=x<=3
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT