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
Nila has created a report, and now she would like to a create table of contents. Nila has reviewed her report and decides to add
Alenkinab [10]

Answer:

The answer is "heading"

Explanation:

Headings, which appear into your document must be marked simply, objectively and correctly because it shows the final report structure and enable to easy access with specific information.  

  • It also promotes to read the document. So, its consistency is ensured in the headings.
  • In sort documents, it can't require any heading, but it Nila created a report, in which she requires  heading and then she update the content of the tables, and other choices can't be described in the given scenario, that's why it is correct
5 0
3 years ago
Plese give three examples of specilized servers.
MariettaO [177]
1.Extended border node (EBN)
2.Central directory server (CDS)
3.Branch extender (BEX or BrEx or BrNN)
5 0
3 years ago
Read 2 more answers
What does ;-; mean during a text?
zzz [600]

Answer:

Its like an emotionless crying face, mainly used for humor

Explanation:

5 0
3 years ago
Read 2 more answers
To share a server folder, access the ____ tab in the folder properties dialog box and click the share button (or from the window
anygoal [31]
Oh lord I have no idea :/ I suck at this yeah idk
5 0
3 years ago
Robert's computer is not starting due to an error in the BIOS. Which of these chips could have malfunctioned? Select the correct
timofeeve [1]

Hi;

In the question, Robert gives the explanation that there is an error in the BIOS. A BIOS (Standing for Basic Input & Output System) is a ROM chip, and is vital for the computer to initialize devices such as RAM, the CPU, etc. If there is ever an error there, a computer simply cannot boot.

From the options given, your answer given would be C. ROM.

I hope this helps!

8 0
3 years ago
Other questions:
  • Tower defense is included under which genre of game
    15·2 answers
  • Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit t
    13·1 answer
  • ORANGE COLORED SIGNS AND FLAGS MEAN THAT YOU MUST BE ALERT FOR:
    8·2 answers
  • When it comes to safety, the choice to be safe is often up to __________?
    8·1 answer
  • Please help
    14·1 answer
  • A manager wants to set up an area that is not on the LAN but not quite on the Internet. This area will house servers that will s
    5·1 answer
  • Which factor did not contribute to the increase of leisure travel in the early twentieth century in the United States?
    7·2 answers
  • Which of the following is a valid HTML reference to a CSS file?
    13·1 answer
  • Immigrants are allowed to enter the country to work when they have a(n)
    10·1 answer
  • Five types of conflict in the school​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!