for the srando function, then create a random array with 10 integers that range
ID: 3850369 • Letter: F
Question
for the srando function, then create a random array with 10 integers that range from 1 to 88. The program should display the original random array to the screen. Use the bubble sort routine discussed in class to sort the array. The program should display the array, current pass number, and the total number of swaps made for each pass. Bonus (+5): Make this a sentinel-controlled program. 3 PE 06 03 (Linear Searching Arrays Generate a random array with 15 integers from 50 to 99. Prompt the user to enter a valid integer search "key between 50-99 and verify the user input. Use the linear search algorithm discussed in class to find the "key" value and array index location of the "key" value. If no value was found prompt the user to enter another number until a value is found. Display the random array to the screen only after the user finds a correct value for comparison. 4) 06 04 (Binary Searching Arrays) Generate a random array containing 15 integers from 10 to 25. Prompt the user to enter a valid integer "key" between 10 25 and verify the user input. Use the binary search algorithm discussed in class to find the value and location of the value. If no value was found prompt the user to enter another number until a value is found. Display the random array to the screen only after the user finds a correct value for comparison. ng random integers from 1 a y 5) PE 06.05 (Two-by-Tw Page 2 0 to 0. Combine the to 10. Create a two-by ay array A B and C to Dis elements of A B using a forloop to Create anayll.lLEAExplanation / Answer
#include <stdio.h>
#include<stdlib.h>
int main()
{
int array[100], search, c, n;
int min=50;
for (c = 0; c < 15; c++)
array[c]=min+(rand()%50);
printf("Enter the number to search ");
scanf("%d", &search);
for (c = 0; c < 15; c++)
printf("%d ",array[c]);
for (c = 0; c < 15; c++)
{
if (array[c] == search) /* if required element found */
{
printf("%d is present at location %d. ", search, c+1);
break;
}
}
if (c == 15)
printf("%d is not present in array. ", search);
return 0;
}
Input :
99
output:
Enter the number to search
83
86
77
65
93
85
86
92
99
71
62
77
90
59
63
99 is present at location 9.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.