Sep 27, 2017 at 3:21pm UTC
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;
}
Sep 27, 2017 at 3:50pm UTC
You need to create an array and assign some values in your main function and then pass it to printArray function.
Sep 27, 2017 at 4:58pm UTC
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 Sep 28, 2017 at 11:29am UTC
Sep 27, 2017 at 5:48pm UTC
Thank you Thomas1965, and thank you MikeyBoy
Sep 28, 2017 at 11:30am UTC
You're welcome - I hope it was helpful in getting your code working?