C LANGUAGE Randomly generate 50 integers within the range of 0 – 999. Store the integers in an array.Pass the array to different functions that perform the tasks below: i. Print out the randomly generated integers in 5 rows, each row having 10 integer. Input: array return: none Random integer generation: #include rand(); //generate random integer rand()%999; //generate random integer between 0-999 ii. Show the range of integers generated: Output the smallest and largest integer and their index in the array.
C LANGUAGE
Randomly generate 50 integers within the range of 0 – 999. Store the integers in an array.Pass the array to different functions that perform the tasks below:
i. Print out the randomly generated integers in 5 rows, each row having 10 integer.
Input: array
return: none
Random integer generation:
#include<stdlib.h>
rand(); //generate random integer
rand()%999; //generate random integer between 0-999
ii. Show the range of integers generated: Output the smallest and largest integer and their index in the array.
Input: array
return: none
iii. Sort the integers in ascending order
Input: array
return: none
findsmallestnumber(int start, int end, array)
input: start index of array, end index of array, array
return: smallest number index or position in array
iv. Generate another array of 50 integers. Compare the 2 arrays and count the similarity percentage of the 2 arrays.
Input: Array1, Array2
Return: none
** Use 2 for loops for this function, One to loop Array1 and another one inside to
loop Array2
Sort
sort(array)
{
loop(array start to end)
{
smallestNumberIndex = findsmallestnumber(array, currentindex, end);
if (currentIndex != smallestNumberIndex)
{ //swap places
temp =array[smallestNumberIndex];
array[smallestNumberIndex] = array[currentIndex];
array[currentIndex] = temp;
}
}
}
![Example of sorting strategy:
arr[] = 64 25 12 22 11
// Find the minimum element in arr[0...4]
// and place it at beginning
11 25 12 22 64
// Find the minimum element in arr[1...4]
// and place it at beginning of arr[1...4]
11 12 25 22 64
// Find the minimum element in arr[2...4]
// and place it at beginning of arr[2...4]
11 12 22 25 64
// Find the minimum element in arr[3...4]
// and place it at beginning of arr[3...4]
11 12 22 25 64](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe20081f6-3e71-4df1-8a15-056fbe8295f3%2F358041e5-041d-465c-a175-b5cb1356ca15%2Fdyjglr8_processed.png&w=3840&q=75)
![Sample output
1st generated array
Output array items:
673
618
429
770
894
370
458
942
383
165
154
832
91
538
242
607
718
598
18
503
653
868
991
954
86
99
647
808
176
129
506
856
705
767
694
421
349
935
802
317
233
127
419
854
987
949
564
454
449
268
Smallest int: 18
Largest int: 991
Index: 15
Index: 19
Sorted Output array items:
18
242
454
653
854
86
91
99
127
129
154
165
176
233
268
317
349
370
383
419
421
429
449
458
503
506
538
564
598
607
618
647
673
694
705
894
718
767
770
802
808
832
856
868
935
942
949
954
987
991
2nd generated array
Output array items:
229
59
139
138
496
91 similar
718 similar
808 similar
3 numbers similar. 6.0 % similarity.
148
102
896
613
319
762
968
91
300
301
37
460
163
938
746
160
90
829
381
656
229
544
229
906
210
482
493
639
222
20
749
718
574
820
916
451
409
561
338
977
546
989
761
878](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe20081f6-3e71-4df1-8a15-056fbe8295f3%2F358041e5-041d-465c-a175-b5cb1356ca15%2F2jl7nev_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)