10 x 10 complex array


Dear All,

I am trying to create a 10 x 10 complex array. I am having a little trouble below is my written code

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cmath>
#include <vector>
#include <cassert>
#include <complex>


using namespace std;
using cmplex = complex<double>;


void printArray(complex<double> A[10][10])
{

cout << endl << endl << "ARRAY" << endl;

for(int i = 0; i < 10; i ++)
{
for(int j = 0; j < 10; j ++)
{
cout << A[i][j] << ' ';
}//j
cout << endl;
}//i

cout << endl << endl;
}

int main ()
{
int i,j;
for(int i = 0; i < 10; i ++)
{
for(int j = 0; j < 10; j ++)
{

printArray << A[i][j] << endl;

cout << endl;
return 0;
}




You need to create an array and assign some values in your main function and then pass it to printArray function.
1) Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) In main(), you haven't actually declared your array A.

3) This:

printArray << A[i][j] << endl;

makes no sense. It looks like a weird mixture of trying to tall your printArray() function, and trying to do stream output. I suspect you need to go back to your textbook and look up the sections on both those things, and learn how to do them properly.
Last edited on
Thank you Thomas1965, and thank you MikeyBoy
You're welcome - I hope it was helpful in getting your code working?
Topic archived. No new replies allowed.