Question: Exercise1: Present and realize in C ++ a program for counting the frequency of the elements stored in an array. These elements are integers between
Exercise1: Present and realize in C ++ a program for counting the frequency of the elements stored in an array. These elements are integers between 0 and 99 (where n= 8):
Exercise2: We have an array of integers, ordered by increasing value, each integer which can be repeated several times: 3 5 5 5 7 9 9 9 9 10 10 10 12 12 12 13 We call a plateau the sequence of all consecutive integers of the same value: in the example above the plateau of value 5 has 3 numbers, that of value 9 has 4, that of value 10 has 3, etc. We call the length of a plateau, the common value of all these terms. An array has n terms given, find the length and value of its longest plateau. Write a program that allows you to determine the length and value of the longest plateau of n integers. (Where n = 16)
Exercise 3: Realize in C ++ a program that determines the most frequent element in an array. ( where n= 8)
Exercise 4: (Static Array vs Dynamic array) Run the following program, write your observation, and explain your output?
/* syntax of creating Dynamic Array ------------------------------- datatype * name_of_Dynamic_Array name_of_Dynamic_Array = new datatype[size] name_of_Dynamic_Array[0]= value . . delete [] = name_of_Dynamic_Array */ #include using namespace std; int main() { int x, n; int arr1[3]; // static array int* arr = new int[3]; // dynamic array cout > arr1[x]; } cout > arr[x]; } cout > n; arr = new int[n]; for (x = 0; x < n; x++) { cout > arr[x]; } cout > n; arr1[n]; for (x = 0; x < n; x++) { cout > arr1[x]; } cout << "You entered for Dynamic array: "; for (int j = 0; j < n; j++) { cout << arr1[j] << " "; } cout << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
