Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FOR C++ WRITE PROGRAM TO UTILIZE POINTER ADDRESSING INSTEAD OF ARRAY SUBSCRIPTING Functional Requirements: A menu-driven program that offers the user 5 options as follows:

FOR C++
WRITE PROGRAM TO UTILIZE POINTER ADDRESSING INSTEAD OF ARRAY SUBSCRIPTING
Functional Requirements:
A menu-driven program that offers the user 5 options as follows:
Menu:
1. Display array
2. Multiply each element in the array by 3.
3. Swap the values in row two with the values in row three.
4. Calculate the SUM of all elements and display that number.
5. Exit
Programming Requirements:
In main(), declare and initialize a 2-dimensional array that contains 5 x 5 elements. Initialize the elements to:
1,2,3,4,5
-20, -40,-60, -80, -100
3,3,3,3,3
5, 7, 9, 11, 13
-15, -25, -35, -45, -55
Display the menu and then execute the user's choice. Keep displaying the menu (and executing the user's choice) until the user chooses Option 5.
1. Declare an int array and initialize it as before. (You can't point at a 2D array in C++, so create an 1-dim array with 25 elements.)
2. Declare an int pointer and point to the array. From then on in the program, you may only use the pointer. You may not use the array or any array subscripting in any other part of your program. You must only use pointer addressing.
3. Always display the array and manipulate it as if it were still a 2-dim array of 5x5.
4. Make sure your code is well-organized and well-documented. No global variables. Use functions and parameters appropriately.
In menu option 2, please triple the actual values in the array. Don't print the array. That's a different menu option.
In menu option 3, please swap the actual array values. Don't display the array. That's a different menu option.
Programming Notes:
Small example about setting up the pointer and not using array subscripts:
int balance[4] = {100, 2, 3, 17}; //here I am declaring my array
int *point; // declaring the pointer
point = balance; //pointing to the array
for ( int i = 0; i < 3; i++ )
cout << *(point + i) << endl; //using the pointer to access array elements
SHOW PROGRAM WORKS WITH A PICTURE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago

Question

Q .1. Different ways of testing the present adulterants ?

Answered: 1 week ago

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago