Question: This lab needs a header and .cpp file I have done my .cpp file not sure if it is correct though: Below is a detailed

This lab needs a header and .cpp file

I have done my .cpp file not sure if it is correct though:

Below is a detailed description of the lab i need done in prep for my project. could someone please compelte this and reply back with the files, please dont post hte actual source code please attach files.

For this lab, we are turning our attention to arrays. An array is a sequential storage unit. So in general it can store more than 1 of a data type. Each element of the array is stored at an index position and those indices start at 0. So for example, if an array has space for 10 ints, they will be stored in index positions 0-9.

Details

You access the individual array elements with [ ] and you put a number in the []. For example, if our array is called myArray and it has size 10, then we could access the first spot like this:

myArray[0] 

It is an error to put a number that is not within the array indices bounds. It is your job as the programmer to ensure that never happens. This lab is focusing on making sure that doesnt happen. In my tests, I will be giving you index numbers that are in fact too large or too small.

Input The input for this program will be a number followed by a character. The number represents the index position where the character is to be stored. You must make sure the given index is valid. If it is, then store the character at the given index location. If it not valid, then dont do anything.

1 x 2 a 3 q 30 r 25 r -1 z 0 t 

We will make our array to be of size 30. If an index number is repeated, and it is valid, then we will simply replace what was there.

After you finish reading all the data, you will simply print the entire array in the form shown below.

Output

Index Letter 0 t 1 x 2 a 3 q 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 r 26 27 28 29 

What is in the output is a header line that indicates what is in the columns below. The first column is the index number and the second column is the contents of the array at the given index location.

As you know, if you dont initialize a variable, then you dont know what is in it. Since the data is character data, the array should be of type char. We can use the space character to initialize our array. The space character is and wont show anything when printed and can be used to initialize our array. I suggest using a for loop to initialize all 30 index locations to the space character.

Requirements

Below are the requirements for the lab:

You must declare the function void arrayChecking( string input, string output ); in a file named: lab8.h

Your array must be of size 30.

Your array must be of data type char.

You must initialize your array to the space character,

You must implement your function in a cpp file.

Below is my .cpp file

==================================================================

#include using namespace std;

int main() { char myArray[30]; int totalChar, loc; char indexChar = ' '; for(int i = 0; i<30; i++) { myArray[i] = ' '; }

cout<<"How many charcters you want to enter"< cin>>totalChar;

for(int j = 0; j { cin >> loc; cin >> indexChar; myArray[loc] = indexChar; }

cout<<"Index Letter"< for(int k = 0; k<30; k++) { cout<

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!