
pls give mommens by expression and statements , thanks
Recall that in C++, there is no check on an array index out of bounds. However, during program execution, and array index out of bounds can cause serious problems. Also, in C++, the array index starts at zero.
Design and implement the class myArray that solves the array index out of bounds problem, and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements:
myArray<int> list(5); //Line 1
myArray<int> myList(2, 13); //Line 2
myArray<int> yourList(-5, 9); //Line 3
This statement in line one declares list to be an array of five components, the component type is int, and components are: list[0], list[1],…, list[4]; the statement in line two declares myList to be an array of 11 components, the component type is int, and the components are: myList[2] myList[3], … myList[12] ; the statement in line three declares yourList to be an array of 14 components the component type is int, and the components are: yourList[-5], yourList[-4], … yourList[0], … , yourList[8]. Write a program to test the class myArray
![Creating: myArray list1(5)
Creating: myArray list2(5)
Output Tistí: cout « "Ìist1 :
list1 : 0 0 o 0 o
« list1 « endl;
Enter 5 integers for list1: 10 200 3000 40000 500000
After filling list1: 10 200 3000 40000 500000
set list2 equal to listl: list2_= list1
Output list2: cout <« "list2 : "
list2 : 10 200 3000 40000 500000
« list2 <« endl;
Enter 3 elements for list1: 999 666 333
First three elements of list1: 999 666 333
Creating: myArray list3(-2, 6)
Output Tist3: cout « "list3 :
list3: 0 0 0 0 0 o o o
« list3 « endl;
Set elements for list3: list3[-2]
= 7;
list3[4] = 8;
list3[0]
54;
%3|
Output list3: cout <« "list3 :
list3: 7 0 54 0 15 0 8 0
list3[2]
list3[4] + list3[-2];
« list3 << endl;](https://content.bartleby.com/qna-images/question/a18bdbf1-c485-406c-b467-ce2c3cd2814d/cbfd3b90-84f5-4ba3-ba3d-cd3c16099ee1/qbtqmrm_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- In C++, Can you please look at the code below and revise/fix so it will work according to instructions and criteria. Instruction 1) Write a function that copies a 1D array to a 2D array. The function’s prototype is bool copy1DTo2D(int d1[], int size, int d2[][NCOLS], int nrows); where size > 0 NCOLS > 0 nrows > 0 NCOLS is a global constant size = NCOLS * nrows the function returns true if the parameters and constants satisfy these conditions and false otherwise. the relation between 1d array indices and 2d array indices is 2d row index = 1d array index / NCOLS 2d column index = 1d array index modulus operator NCOLS 2) Write a function that copies a 2D array to a 1D array. The function’s prototype is bool copy2DTo1D(int d2[][NCOLS, int nrows, int d1[], int size); where size > 0 NCOLS > 0 nrows > 0 NCOLS is a global constant the function return true if the parameters and constants satisfy these conditions and false otherwise. the relation between 1d array indices and…arrow_forwardLanguage is C++arrow_forwardPlease use C++ and make sure it's for a sorted array Write a function, removeAll, that takes three parameters: an array of integers,the number of elements in the array, and an integer (say, removeItem). Thefunction should find and delete all of the occurrences of removeItem in thearray. If the value does not exist or the array is empty, output an appropriatemessage. (Note that after deleting the element, the number of elements in thearray is reduced.) Assume that the array is sorted.arrow_forward
- Write answer in c++.arrow_forwardIn GO language. Create a struct that has student name, id, and GPA. Write functions to create a student, modify the student’s id, and modify the student's GPA, and print the student’s information. (This is like creating a class and methods). Now create an array of three students and test your functions. You may hardcode your values if using a web conpiler. (Please hardcode the values!)arrow_forwardWrite a C++ Program using classes, functions (recursive and otherwise), arrays and other C++ commands that reads words from a file (one column only), storing them into an array. Once the array is sorted alphabetically ascending, the user is prompted to enter a word. The program reports whether or not the word was in the array of words. and its position on the array. If the word is found, the program should report the number of letters in that word.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





