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
c++ programming question: Use the random number generator in class Random to store a list of...
c++ programming question: Use the random number generator in class Random to store a list of 1000 random integer values in an array.   Create 3 arrays using this method. Apply each of the insertion, bubble, selection and shell sort algorithms to each array. Determine the number of comparisons and exchanges for each sort algorithm for each array. create table to print out the results. first array second array third array comparisons exchanges comparisons exchanges comparisons exchanges insertion bubble selection shell
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)
(C++)Randomized Quicksort: Write C++ codes for randomized quicksort. You may need rand() to generate random numbers....
(C++)Randomized Quicksort: Write C++ codes for randomized quicksort. You may need rand() to generate random numbers. Run the randomized quicksort 5 times for input array A = {1, 2, 3, …, 99, 100} and report the 5 running times.
In C++ Write a simple program to generate random integers between X and Y and store...
In C++ Write a simple program to generate random integers between X and Y and store them in a file, one number per line. The user should input the number of elements to generate and the boundary numbers X and Y (e.g. the inputs 100, 0, 999 mean your program should generate a list of 100 integers with values between 0 and 999, inclusive).
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...
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.
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT