#include <iostream> #include <cstdlib> using namespace std; /* Prints the given
ID: 3542846 • Letter: #
Question
#include <iostream>
#include <cstdlib>
using namespace std;
/* Prints the given integer array to the screen.
*
* Require: size >= 0 &&
* size == array[last+1];
* Ensure: Only array memory location are traversed &&
* output format: "{ x,y,z }"
*/
void stringifyArray(int array[], int size);
int main() {
int integers_one[3] = { 0,1,3 };
int integers_two[2][3] = {{ 0,1,2 },{2,3,4}};
cout << "Integer array: " << endl;
stringifyArray(integers_one, 3);
exit(EXIT_SUCCESS);
}
Explanation / Answer
please rate - thanks
any questions - ask
#include <iostream>
#include <cstdlib>
using namespace std;
#define length(a) ( sizeof ( a ) / sizeof ( *a ) )
/* Prints the given integer array to the screen.
*
* Require: size >= 0 &&
* size == array[last+1];
* Ensure: Only array memory location are traversed &&
* output format: "{ x,y,z }"
*/
void stringifyArray(int array[], int size);
int main() {
int integers_one[3] = { 0,1,3 };
int integers_two[2][3] = {{ 0,1,2 },{2,3,4}};
cout << "Integer array: " << endl;
stringifyArray(integers_one, 3);
exit(EXIT_SUCCESS);
}
void stringifyArray(int array[], int size)
{int i;
cout<<"{";
for(i=0;i<size-1;i++)
cout<<array[i]<<",";
cout<<array[i]<<"} ";
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.