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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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 Algorithm Pseudocode:
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
Transcribed Image Text: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
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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education