Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Waubonsee Community College CIS130 C++ Programming Spring 2018 Maya Tolappa Test 3 hand on Portion (50 points) The purpose of this test is to test

Waubonsee Community College CIS130 C++ Programming
Spring 2018 Maya Tolappa
Test 3 hand on Portion (50 points)
The purpose of this test is to test your knowledge of arrays and pointers.
You may change line 24 to use a SMART POINTER if you wish!
Consider the following cpp file that is part of the solution provided to you. Download it by clicking this link or from BlackBoard.
#include
#include
#include
#include
#include
using namespace std;
int main()
{
srand(time(NULL));
string arr_inst_names[10] = { "Georgette","Francene", "Earle",
"Hsiu", "Antonio", "Gema",
"Wallace","Josefina","Belia",
"Margaretta" };
//********************** 5 points *******************
//code a loop to print out the contents of the arr_inst_names array
//generate a random number as per specifications and assign it to
//the arr_size variable
int arr_size;
string *ptr_to_names_arr;
//create a string array with arr_size elements and place address
//of this newly created array into the ptr_to_names_arr pointer
//variable.
//Populate this newly created array from elements in
//the arr_inst_names array
//********************** 5 points *******************
cout
//**************** 15 points for print_arr function **************
//The print_array function prints the elements in the array whose
//address is maintained in the ptr_to_names_arr pointer
//Remember to create a function prototype for the function
print_array(ptr_to_names_arr, arr_size);
//**************** 15 points for sort_arr function **************
//The sort_array function must sort the elements in the array whose
//address is maintained in the ptr_to_names_arr pointer
//as per specifications. Remember to create function prototype
sort_array(ptr_to_names_arr, arr_size);
cout
print_array(ptr_to_names_arr, arr_size);
//**************** 10 points deletion statement.**************
//delete the memory taken up by the array whose address is maintained in
//the ptr_to_names_arr pointer
//****** Automatically awarded when you use smart pointers! *********
return 0;
}
In order to complete this program, complete these steps:
Task
Points
1.
Code a loop to print out the contents of the arr_inst_names array
5
Place a random number between 4 and 8 in arr_size
Create a string array with arr_size elements and place address of this newly created array into the names_arr pointer variable. Populate this newly created array from elements in the arr_inst_names array.
Implement print_array function
Implement sort_array function to sort elements in ascending order
Delete space taken up by dynamically created array.
You can when you use a smart pointer!
The output from my implementation of the program looks like this.:
Georgette Francene Earle Hsiu Antonio Gema Wallace Josefina Belia Margaretta
---Before sort---
Array size = 4
Georgette Francene Earle Hsiu
---After sort---
Array size = 4
Earle Francene Georgette Hsiu
image text in transcribed
The output from my implementation of the program looks like this.: Georgette Francene Earle Hsiu Antonio Gema Wallace Josefina Belia Margaretta -Before sort-- Array size 4 Georgette Francene Earle Hsiu -After sort-- Array size = 4 Earle Francene Georgette Hsiu

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_2

Step: 3

blur-text-image_3

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

In Exercises, find the limit. lim x0 5r2 + 2 x + 3

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago