Question: Q 1 ) Write a C + + program that can read data from an input file ( provided at the bottom ) into a

Q1)Write a C++ program that can read data from an input file (provided at the bottom) into a
one dimensional array (dont use vector) and perform the following functions:
1) A function to check if a certain integer exists in the array if the number is present return the
index where the number is present.
2) A function that can modify the value of an integer when called with the index of the integer in
the array and return the new value and old value back to the user.
3) A function that adds a new integer to the end of the array
4) A function which intakes an index of an array and replaces the value with either 0 or removes
the integer altogether.
Q2) A way to indicate an error, especially if there are several possible errors in code, is
through the use of exceptions. Exceptions are used to signal that an error has occurred. You can insert
code in your program that throws an exception when a particular kind of error occurs. An exception
handler allows the user to catch or handle the exception. To avoid uncaught exceptions, you write a try
block that can throw an exception and follow it with a catch block that catches the exception and
handles it. Using the array code from question 1 perform the following:
1) Add a try and catch blocks to the user inputs for the following functions from question 1:
A function that can modify the value of an integer when called with the index of
the integer in the array and return the new value and old value back to the user.
A function that adds a new integer to the end of the array input file: 12345678910
11121314151617181920
21222324252627282930
31323334353637383940
41424344454647484950
51525354555657585960
61626364656667686970
71727374757677787980
81828384858687888990
919293949596979899100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!