Question: The attached program (PointersStringsAssignment.cpp) is a program tat has 6 parts (functions) named Demo01 ~ Demo06) There is a block of comments at the beginning

The attached program (PointersStringsAssignment.cpp) is a program tat has 6 parts (functions) named Demo01 ~ Demo06) There is a block of comments at the beginning of each function which are the instructions to complete that function

assignment

1. complete demo04

2. choose any two other functions and complete them

************************************************

Code this program:

/****************************************** * library includes ******************************************/ #include // needed for I/O

/****************************************** * pre-processor ******************************************/ #define PI 3.14159 using namespace std;

/**************************************** * classes ****************************************/ /**************************************** * member functions ****************************************/ /**************************************** * function prototypes ****************************************/ void demo01(); void demo02(); void demo03(); void demo04(); void demo05(); void demo06();

/***************************************** * main() - the function that executes *****************************************/ int main() { /******************************* * local variables * *******************************/ demo01(); demo02(); demo03(); demo04(); demo05(); demo06(); system("pause"); return 0; } // end main

/***************************************** * 1. declare a 2 dimentional array * of characters to hold the names * of the months * char monthName[12][15]; * 2. initialize each row of the array * with the proper month name * use strcpy to do this * 3. print month names - one per line *****************************************/ void demo01() { cout << " **** in Demo01 **** "; // declare char monthName[12][15]; // initialize // print } /***************************************** * * same as demo01 except you declare and * initialize the array in one line * * 1. declare a 2 dimentional array * of characters to hold the names * of the months * char monthName[12][15]; * 2. initialize the array with the proper * month name when you declare the array * 3. print month names - one per line *****************************************/ void demo02() { cout << " **** in Demo02 **** "; // declare and initialize char monthName[12][15]= {"?????"}; // print }

/***************************************** * * same as demo02 except you declare the * array with [] rows and [15] columnsand * char monthName[][15] * * 1. declare a 2 dimentional array * of characters to hold the names * of the months * char monthName[12][15]; * 2. initialize the array with the proper * month name when you declare the array * 3. print month names - one per line *****************************************/ void demo03() { cout << " **** in Demo03 **** "; // declare and initialize char monthName[][15]= {"?????"}; // print } /***************************************** * * using pointers * * 1. declare an array of 12 char pointers * char* monthName[12]; * 2. allocate memory for each pointer * 3. initialize (dereference) each pointer * with the proper month name * 4. print month names - one per line *****************************************/ void demo04() { cout << " **** in Demo04 **** "; // declare char* monthName[12]; // allocate memory // load month values // print } /***************************************** * * using pointers * * 1. copy the function demo01() or demo02() * (start with one of those) * 2. declare a char pointer * 3. make the pointer point to the array * 4. print month names - one per line * using the pointer *****************************************/ void demo05() { cout << " **** in Demo05 **** "; // declare. instanciate and load the array // code for demo01() or demo02() // create a char pointer char* pMonthName; // make pointer point to the array // print array using the pointer } /***************************************** * * using pointers - you probably have some * of this code in demo05() * * 1. start with demo05() ???? * 2. declare a char pointer * 3. allocate 180 characters of memory * (12 * 15 = 180) * 4. load the month names (using the pointer) * 4. print month names - one per line * using the pointer *****************************************/ void demo06() { cout << " **** in Demo06 **** ";

// create a char pointer char* pMonthName; // allocate memory pMonthName = new char[180]; // load month names // print array using the pointer }

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!