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]
4 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]4 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
Robert brought 10 shares apex company for $18 each and later sold all of them at $17 each. This transaction resulted in what typ
Ghella [55]

Answer:

$1 loss

Explanation:

purchase share=$18

Sold share=$17

Profit/Loss statement=sell- purchase=17-18=-1

If it contain negative value so it is loss

Loss=$1

4 0
3 years ago
Read 2 more answers
The state department that issues driver's licenses would like a police officer to be able to scan the driver's license and insta
frozen [14]

Answer:

The technology that the state should use is the Optical Character Recognition or OCR system which comprises of a driver license card with bar code or optical code character engraved on it that can be read by optical scanners that are then linked via the internet to access the recorded data regarding the card holder, including outstanding tickets and warrants.

With the system, a police will be able to both verify the authenticity of the drivers license and get answers to questions about the vehicle driver

Explanation:

6 0
3 years ago
I need help with this problem please
alina1380 [7]

Answer:

i think its d

8 0
3 years ago
If str 1 and str2 are both Strings, which of the following expressions will correctly
Novosadov [1.4K]
Str1==str2 is the answer
3 0
4 years ago
Identify a stressor in your life. Conduct an internet search to locate at least two reliable sources of information on effective
Gre4nikov [31]

Answer:

The biggest stressor in my life is certainly accountancy. I need to divide my earning among my family members, however, I had to work as well. and hence, I wanted to cover this automatically. I decided to surf the internet. I realized I need to first find the keyword. And I found it as budgeting and the monthly income. I got all my answers. The source explained to be how I can transfer a part of my income to each of my family members, and also to grocery sites like Amazon, the daily service provider who provide various home servants, for electricity bills, yearly water tax, house tax, and all my expenses. And now I can relax and work, as with one click, I can now pay all my bills, as well as I can order for instant food deliveries, call plumbers, electricians, etc any time and everything I can think of. I have no headache now, and I can devote all of my hours to work. And that has also increased my income since I went automatic.

Explanation:

Thus, we need to first find the keyword, and then find the best site from the list that appears. And then we need to research through that site and find the solution.We can make use of the search engine commands as well.

4 0
4 years ago
Other questions:
  • Many people blame online shopping for the demise of the high street. Discuss why high street shops find it difficult to compete
    12·1 answer
  • In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints {
    13·1 answer
  • Which class of fire extinguisher is appropriate for a fire involving electrical/energized electrical equipment?
    13·2 answers
  • After you save a table, the new table name appears ____.
    12·2 answers
  • Which is true about POP3 and IMAP for incoming email?
    14·1 answer
  • What factors contribute to food wastage
    12·1 answer
  • What made it possible to develop personal computers?
    10·2 answers
  • Big data are used to _____. Select 3 options.
    5·1 answer
  • Draw a flowchart that ask the user to enter number: if the number is less than then 10 number it is doubled if the number is mor
    7·1 answer
  • What is it called when a programmer includes a step in an algorithm that lets
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!