Write a function that displays the contents of an array in a predefined format with
the value of index 0, displayed last.
#include <iostream>
using namespace std;
template <typename T, int n>
void display_content (T const(& arr)[n])
{
for (int i = 1; i < n; i++)
{
cout << arr[i] << ", ";
}
cout<< arr[0]<<endl;
}
int main()
{
//example work function display_content
int test[] = { 17,25,48,98 };
display_content(test);
double test_11[] = { 3.2,7.8,9.87,99,104 };
display_content(test_1);
char test_2[] = "abcfd";
display_content(test_2);
return 0;
}
Comments
Leave a comment