1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gre4nikov [31]
3 years ago
6

Write a program that sorts an array of 20 random numbersin the range from 0 through 1000.

Computers and Technology
1 answer:
Nuetrik [128]3 years ago
6 0

Answer:

#include<iostream>

#include<stdlib.h>

#include<time.h>

#include <algorithm>

using namespace std;

//main function program start from here

int main(){

   //seed the rand() function

   srand(time(NULL));

   //initialization

   int arr[20];

   //generate the 20 random number

  for(int i=0;i<20;i++){

   arr[i]=rand()%1000;   //store in array

  }

  sort(arr,arr+20); //sort the array by inbuilt function

  cout<<"The sorted array is."<<endl;

  //for display the each element in the array

  for(int i=0;i<20;i++){

   cout<<arr[i]<<endl;

  }

}

Explanation:

Create the main function and declare the array with size 20.

Take a for loop and generate the random number 20 times. For generating a random number, use the function rand();

rand() function which defines in the library stdlib.h, generate the random number within the range.

for example:

rand() % 20: generate the number between 0 to 19 ( Exclude 20).

for generating the random number different for every time, then we have to use srand() function and time function which defines in time.h library.

After that, store the number in the array.

Finally, take another loop and print all elements one by one.  

You might be interested in
Only Lysita knows the password for the question......
emmasim [6.3K]
The correct answer is 1234.

7 0
3 years ago
Which of the example DFSs discussed in this chapter would handle a large, multiclient database application most efficiently? Exp
Tju [1.3M]

Answer: A.F.S- known as Andrew File System.

Explanation:

This is a distributed network file system created to handle large multiclient database. It support Information sharing on a large scale by reducing client-server communication.

3 0
3 years ago
Jamie has to enter the names, grades, and scores of a group of students into a worksheet. Which option will Jamie use to describ
GuDViN [60]

Answer: B. graphs

Jamie can use graphs to describe the data she enter such as names, grades and the scores of the group of students. In addition, using graphs will allow the reader to create visualization of the data, which will help the reader to easily understand and define the main purpose of the data entered.

7 0
3 years ago
Read 2 more answers
Which of the following do you need to remeber about true/false questions?
lina2011 [118]
All parts of a statement must be true for it to be true
7 0
3 years ago
X = 10<br> y = 20<br> x &gt; У<br> print("if statement")<br> print("else statement")
Ksenya-84 [330]

Answer:

n

Explanation:

n

5 0
3 years ago
Other questions:
  • Which finger types the return or enter key?
    6·2 answers
  • In the ADT graph the methid addVertex has efficiency
    15·1 answer
  • Write a program to compute answers to some basic geometry formulas. The program prompts the user to input a length (in centimete
    7·1 answer
  • Video-sharing sites such as youtube and vimeo provide a place to post short videos called clips, true or false?
    10·1 answer
  • Identify three best -selling tablet on the market, and decide on the one that you would like to buy? justify your respone
    9·1 answer
  • Ano ang ibig sabihin ng tanka<br>​
    5·1 answer
  • Who are the following furries?
    10·2 answers
  • Write a program to Test if mold is stored in the variable word.
    5·1 answer
  • Maria needs to use a requirement-gathering method that will help her provide a set of questions to the client. Which method shou
    11·1 answer
  • To set up scenarios,then set up a list, then set up the reference cell. to set up the cells that display the output results from
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!