Question

In: Computer Science

Inc++ seed the randomnumber generator, one time only with 2020 . Create an array...

In c++ seed the random number generator, one time only with 2020 . Create an array with 100 elements. Using a function fill the array with 100 numbers in the range of 101 - 199 that are based off the random number generator. Using a second function search the array and return the smallest value and the index of the element that contains the minimum value.


Solutions

Expert Solution

#include
#include

using namespace std;

void fillArray(int arr[], int size){
  
   for(int i=0; i        arr[i] = 101 + rand()%(199-101+1);
   }
}

int searchMinIndex(int arr[], int size){
  
   int index = 0;
   for(int i=1; i        if(arr[i]    }
   return index ;
}


int main(){
  
   srand(2020);
  
   int arr[100];
  
   fillArray(arr,100);
  
   int minIndex = searchMinIndex(arr,100);
  
   cout<<"Smallest Value in the array is "<    cout<<"Smallest value index is "<< minIndex <

   return 0;
}
===================================================================


Related Solutions

Use Python. Create a Shakespearean Insult Generator The generator takes one element / data chunk from...
Use Python. Create a Shakespearean Insult Generator The generator takes one element / data chunk from each list and combines them to form the Shakespearean Insult. For example - List1 - artless List2 - beef-witted List3 - barnacle Result - Thou is a artless beef-witted barnacle    Your program will have three modes. There is the automatically mode where the program will randomly select one element from each column and combine them. The second mode is the user is presented...
Please enter a seed: 1 Please enter the size of the array: 1 Array size must...
Please enter a seed: 1 Please enter the size of the array: 1 Array size must be greater than 1. Please reenter: 0 Array size must be greater than 1. Please reenter: -1 Array size must be greater than 1. Please reenter: 12 Please choose an option: 1 Print the array 2 Find the average 3 Find the largest element 4 Count how many times 3 occurred 5 Count how many elements are less than half of the first element...
Create a method evenOdd() that sorts an array into even numbers on one side and the...
Create a method evenOdd() that sorts an array into even numbers on one side and the odd numbers on the other side public class ourArray { int[] Ar; int size; public int getSize() {    return size; } public ourArray() {    Ar = new int[100];    size = 0; } public void add(int e) {    Ar[size]= e;    size++; } public int remove() {    //save the last item           int save = Ar[size -1];   ...
Q3 (20%) Crandle Manufacturers Inc. is approached by a potential customer to fulfill a one-time-only special...
Q3 (20%) Crandle Manufacturers Inc. is approached by a potential customer to fulfill a one-time-only special order for a product similar to one offered to domestic customers. The company has excess capacity. The following per unit data apply for sales to regular customers:                                         Variable costs:                                     Direct materials                    $140                                     Direct labor                             100                                     Manufacturing support          105                                                                   Fixed costs:                                     Manufacturing support          175                                     Marketing costs                        65                               Total costs                                     585                               Markup (50%)                             292.5                              ...
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array.
C++ ProgramWrite a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to element 1 of the new array, element 1 of the argument array should be copied to element 2 of the new array, and so forth. The function...
We have an array A of size n. There are only positive integers in this array....
We have an array A of size n. There are only positive integers in this array. Note that the array may have integers that are not distinct, and it could be any array of positive integers in creation (I like the numbers found the decimal expansion of π for instance). When possible provide the exact complexity of the algorithm. If it’s not possible explain the O/Ω/Θ complexity. a. Design an efficient algorithm to find the maximum difference between any two...
We have an array A of size n. There are only positive integers in this array....
We have an array A of size n. There are only positive integers in this array. Note that the array may have integers that are not distinct, and it could be any array of positive integers in creation (I like the numbers found the decimal expansion of π for instance). When possible provide the exact complexity of the algorithm. If it’s not possible explain the O/Ω/Θ complexity. a. Design an efficient algorithm to find the maximum difference between any two...
Write a program in Java to do the following: -Create a one-dimensional array of 7 integers...
Write a program in Java to do the following: -Create a one-dimensional array of 7 integers as follows: Assign {35,20,-43,-10,6,7,13} -Create a one dimensional array of 7 Boolean values as follows: Assign {true,false,false,true,false,true,false} -Create a one dimensional array of 7 floating-point values as follows: Assign {12.0f,1.5f,-3.5f,-2.54f,3.4f,45.34f,22.13f} -Declare sum as integer and set it to 0. -Declare sumf as float and set it to 0.0f. -Use a for loop to go through each element of the Boolean array, and if an...
Create a function to output a one dimensional double array Mwith n elements where the...
Create a function to output a one dimensional double array M with n elements where the first three elements are 1 and each subsequent element is the sum of previous three elements before it. Name the function myArray. Write the function in the correct format to be used to create a Matlab function. Call the function in correct format to output the array with 7 elements.
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for name, one for hours worked,and the last for hourly rate. The arrays will receive the information from inputs from the screen.For example, you will ask the following three questions: a) Employee name: b) Hours worked: c) Hourly rate: After you have received all ten records and have inserted them into the array, you will then calculate the hourly rate times the hours worked to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT