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;
}
1
Expert's answer
2013-04-04T02:55:08-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS