Question: Write a C program that uses the random number generator rand( ) to create an array with 20 numbers in the range from 1

Write a C program that uses the random number generator rand( )

Write a C program that uses the random number generator rand( ) to create an array with 20 numbers in the range from 1 to 50 and disply them in a row. The program sorts the array elements and displays them in decresing order, then calculates and displays the difference between the largest array element and the second largest array element in the array. An example run of the C program is as follows, The initial set of 20 numbers is: 29 17 32 49 42 13 49 42 15 7 14 42 45 26 20 43 The sorted set of 20 numbers in descending order is: 49 49 45 43 42 42 42 39 38 36 32 29 26 20 17 15 14 13 7 1 1 38 39 36 The difference between the lagest array element and second largest array element is: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an example C program that generates an array of 20 random numbers sorts them in descending ord... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!