Multi dimensional Arrays

I'm having trouble figuring out how to program the argument for a multi-dimensional arrays. In this function I am supposed to create an array with two sets of information. One for a random set of integers witch is supposed represent degrees in fahrenheit and the other is the same numbers converted to Celsius.

I tried messing around with it two different ways but I got this error.

error C2664: 'InitializeTemperatures' : cannot convert parameter 1 from 'double [1][2]' to 'int [][2]'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

// multi-dimensional arrays
void InitializeTemperatures(int ma[][2], int xSize);
void PrintArray(double ma[][2], int xSize);
  
 int main()
{
  // This entire main() function will be deleted
  // during the assessment and replaced with
  // another main() function that tests your code.

  // Develop code here to test your functions
  // You may use std::cout in any tests you develop
  // DO NOT put std::cout statements in any of the
  // provided function skeletons unless specificaly asked for

  // Here is a quick array to get you started.
  // This size may change!
  // Make sure your functions work for any array size.
  const int ARRAY_SIZE = 20;
  int a[ARRAY_SIZE];
  // Start here
  // Call your functions and test their output
  // Here is an example
  int seed;
  std :: cout << " Enter a seed value: ";
  std :: cin >> seed;
  SeedRand(seed); // Only call this ONCE
  
  // Did it work?

  std :: cout << " Initializing Temperatres ...\n ";
  std :: cout << " Temperatures = ";
  const int rows = 1;
  const int columns = 2;
  double ma[rows][columns];
  InitializeTemperatures(ma,ARRAY_SIZE);
  PrintArray(ma,ARRAY_SIZE);

std::cout << "Press ENTER";
  std::cin.ignore();
  std::cin.get();
  return 0;
}

void InitializeTemperatures(double ma[][2], int xSize)
{
  // Develop an algorithm that inserts random numbers
  // between 1 and 100 into a[i][0]
  // hint: use rand()
  // These random numbers represent a temperature in Fahrenheit
  // Then, store the Celsius equivalents into a[i][1]
	/*for( int i = 0; i < xSize; ++i) {
		for(int j = 0; j < 2; ++j  ){
	ma[i][1] = 1 + rand() % 100;
	ma[i][0] = 1.8*ma[i][2] + 32;}
	}

}
*/

	   int i, j;
for (i=0; i<xSize; i++)
{
for (j=0; j<2; j++){
if(j==0){ //inserts random numbers
ma[i][0]= rand()% 100 +1; // print 1 to 100
}
else if (j==1){
ma[i][1]= (ma[i][0]-32)/1.8;
}
}}
return;
}
Your function prototype says you're going to pass an array of int, yet your function call and function implementation seem to be using an array of double.

The function prototype, function call and function implementation should all agree as to the type and number of parameters and return type.
Yes there seems to have been a typo o the assignment oh well

thank you
Topic archived. No new replies allowed.