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
_________ is the biggest problem you can face if you don’t identify the scope of your risk management project. Scope creep Nonco
mart [117]

Answer: Scope creep

Explanation:

 Scope creep in the project management basically refers to the uncontrolled development or growth in the project creep. It basically occur when the project scope are not appropriately defined.

It usually involve lack of change in the control system and increase the complexity of the project. It is also has poor requirement analysis.

So, that is why it is the biggest problem we usually face in the project management.

5 0
3 years ago
Assignment 1 silly sentences
ololo11 [35]

Answer:

Sally sells sea shells by the sea shore

Explanation:

3 0
3 years ago
Find at least three software programs for each of the two technologies listed below.
lakkis [162]

Answer:

Android Studio, FileZila

Explanation:

Android studio provides you with all tools you need to build a mobile application l.

FileZila is an FTP controller, you cam DELETE , SEND, RECIEVE data from it.

7 0
3 years ago
Read 2 more answers
Explain the process of creating a linocut. How is it effective? Why is it criticized?
tankabanditka [31]
So making a linocut basically your taking your design and using the negative space to paint the same picture over and over its is a very easy and effective method how every its main drawback is unless you make a bunch of different ones you stuck with one design 
3 0
3 years ago
Read 2 more answers
7. Ctrl + V is used to __________
Pepsi [2]

Answer:

E=Paste

Explanation:

E= Paste the selected text

8 0
3 years ago
Read 2 more answers
Other questions:
  • When approved for a loan, an individual essentially applied for aid in the area of...
    15·1 answer
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • What is the name of the port that you plug an ethernet network cable into?
    6·1 answer
  • What file format is best for photo editing? Select one: a. JPG b. RAW c. DOC d. RTF
    12·2 answers
  • Write code to print the location of any alphabetic character in the 2-character string passCode. Each alphabetic character detec
    8·1 answer
  • Larry finds it easy to run legacy programs and applications in a virtualized environment. how does the virtualization provider m
    7·2 answers
  • Media applications that play audio or video files are part of a class of workkloads called "streaming" workloads (i.e., they bri
    9·1 answer
  • If you are trying to improve your budget and spending, which option would save you the most money?
    13·2 answers
  • Which type of CPU instruction performs arithmetic calculations and stores the results in memory?
    14·2 answers
  • The register in the CPU is not the same as the RAM.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!