# Answer to Question #27666 in C++ for Darren Jackson

Question #27666

How to write the function?

void print (const float x[], const int n){

for ( const float *p = x; p != x + n; ++p ) cout << ’\t’ << *p;

cout << endl;

}

void print (const float x[], const int n){

for ( const float *p = x; p != x + n; ++p ) cout << ’\t’ << *p;

cout << endl;

}

Expert's answer

#include <iostream>

using namespace std;

void print(const float x[], const int n)

{

for (int k = 0; k < n; k++)

cout << '\t' << x[k];

cout << endl;

}

int main()

{

float x[] = {3.2, -5.14, 9.8};

print(x, 3);

return 0;

}

using namespace std;

void print(const float x[], const int n)

{

for (int k = 0; k < n; k++)

cout << '\t' << x[k];

cout << endl;

}

int main()

{

float x[] = {3.2, -5.14, 9.8};

print(x, 3);

return 0;

}

## Comments

## Leave a comment