Question
C++ Programming Question For this exercise you are to implement a virtually initialized array and test it for correctness. The program will prompt for the
C++ Programming Question
For this exercise you are to implement a virtually initialized array and test it for correctness. The program will prompt for the name of an input file and then read and process the data contained in this file.
You will use three integer arrays, data[], forward[] and backward[] each containing 100 elements.
Your test data will consist of a file containing two parts:
1. A sequence of pairs: what, where. You are to store the value what in location where of the data array using virtual initialization. I.e. data[where] = what.
2. This sequence is terminated by the pair 1 1
3. This is followed by a sequence of single integer values, probe. For each such value you are to test whether data[probe] has been initialized and print one of the following two messages: - Position probe has not been initialized.
- Position probe has been initialized to value data[probe].
4. This sequence is terminated by the value 1
A sample input file might contain:
42 7
93 9
11 4
1 1
7
8
9
1
For which the output would be: Position 7 has been initialized to value 42. Position 8 has not been initialized. Position 9 has been initialized to value 93. Do not use classes or STL.
thank you for your help in advance!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started