Problems with my array lab

#include <iostream>
#include <iomanip>
#include <math.h>



using namespace std;

int main()
{
int sumArray;



//1
int arr[] = { 5, 6, 4 };
cout << sumArray(arr, 3) << endl;

//2
int arr[] = { 3, 2, 4 };
cout << convertToDecimal(arr, 3) << endl;

//3
int arr[] = { 2, 5, 8, 3, 9, 9, 7 };
cout << printAccending(arr, 6) << endl;

//4
const int length = 7;
int arr[] = { 1, 2, 4, 5, 6, 9, 10 };
reverse(arr, length);

//5
int grid[3][3];
int arr[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };

}

//Question 1
int sumArray(int arr[], int length)
{
int sum = 0;
for (int i = 0; i < length; i++);
sum += arr[0];
return 0;
}

//Question 2
int convertToDecimal(int arr[], int length)
{
int num = 0, power = length;
for (int i = 0; i <= length; i++);
{
num += (arr[1]) *pow(10, power);
power--;
}
}

//Question 3
int printAccending(int arr[], int length)
{
int i, j, flag = 1;
int temp;
int arrLength = arr.length();
for (i = 1; (i <= arrLength) && flag; i++)
{
flag = 0;
for (j = 0; j < (arrLength - 1); j++)
{
if (arr[j + 1] < arr[j])
{
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
flag = 1;
}
}
}
return;
}


//Question 4
void reverseArrayEven(int arr[], int length)
{
int temp;
for (int i = 0; i <= length; ++i)
{
arr[i] = temp;
temp = arr[length - i - 1];
arr[length - i - 1] = arr[i];
cout << temp << " ";
}
}

//Question 5
void col_row(int grid[][3], int s)
{
int row;
int col;
for (row = 0; row < 3; ++row)
{
for (col = 0; col < 3; ++col)
{
cout << grid[row][col] << " ";
}
cout << endl;
}
}





This is an array lab assigned by my professor. I'm still beginning to get used to arrays.
I'm missing a couple things that I can't figure out:
I'm missing a declaration in int main.
And it is also say I have too many initializer values: (int arr[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };)
Last edited on
What is your problem and please tag your code.
Topic archived. No new replies allowed.