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
|
//Once I run this it just keeps going and I don't know why. any help would be cool
#include <iostream>
#include <cmath>
using namespace std;
const int rows = 2;
const int cols = 3;
void c_area(double[][cols], int);
int main()
{
int row, col;
int r = 2;
double radii[][cols] = {{1.0, 3.0, 5.0}, {7.0, 9.0, 11.0}};
for(row = 0; row < rows; row++)
{
for(col = 0; col < cols; col++)
{
cout << radii[row][col] << " " ;
}
cout << endl;
}
c_area(radii, r);
for(row = 0; row < rows; col++)
{
for(col = 0; col < cols; col++)
{
cout << radii[row][col] << " ";
}
cout << endl;
}
return 0;
}
void c_area(double rad[][cols], int r)
{
for(int i = 0; i < r; i++)
{
for(int j = 0; j < cols; j++)
{
rad[i][j] = rad[i][j] * rad[i][j] * 3.14159;
}
}
}[code]
|
Last edited on
for(row = 0; row < rows; col++)
This will lead to an endless loop since row is always 0;
Wow that was so dumb of me thanks. Plus fixed code tag I hope, first time poster sorry.