Passing array (c++) : Code:


    #include <stdio.h>
    #include <string.h>
    #include <malloc.h>
    #include <stdlib.h>
    #include <math.h>
    #include <assert.h>
    #include <iostream>
    using namespace std;
    
    void case1();
    void case2();
    void case3();
    void case4();
    void case5();
    
    //Global variables
    
    const int MAXROW = 5;
    const int MAXCOL = 5;
    
    int main()
    {
    	char selection;
    	do                                  //menu
    	{
    		cout << "\n\nMENU\n";
    		cout << "1. Enter array 5,5 \n";
    		cout << "2. Find max and min: \n";
    		cout << "3. Average of negatives: \n";
    		cout << "4. Product of numbers different from 0 \n";
    		cout << "5. Output: \n";
    		cout << "6. Exit.\n\n";
    		cin >> selection;
    
    		switch (selection)
    		{
    		case '1': {
    			system("cls");
    			case1();
    		} break;
    
    		case '2': {
    			//system("cls"); 
    			case2();
    		} break;
    
    		case '3': {
    			//system("cls"); 
    			case3();
    		} break;
    
    		case '4': {
    			//system("cls"); 
    			case4();
    		} break;
    
    		case '5': {
    			//system("cls"); 
    			case5();
    		} break;
    		}
    
    	} while (selection != '6');
    
    	return 0;
    
    }
    
    void case1()
    {
    	int A[MAXROW][MAXCOL] = { 0 };
    
    	for (int r = 0; r < MAXROW; ++r)
    		for (int c = 0; c < MAXCOL; ++c) {
    			cout << "\n A[" << r << "][" << c << "]= ";
    			cin >> A[r][c];
    		}
    
    }
    
    void case2()
    {
    	int newarr[MAXROW + 1][MAXCOL + 1] = { 0 };
    	int max[MAXCOL] = { 0 };
    
    	for (int r = 0; r < MAXROW; ++r) {
    		int minr = A[r][0];
    		for (int c = 0; c < MAXCOL; ++c) {
    			newarr[r][c] = A[r][c];
    			if (minr > A[r][c])
    				minr = A[r][c];
    
    			if (max[c] < A[r][c])
    				max[c] = A[r][c];
    		}
    		newarr[r][MAXCOL] = minr;
    	}
    
    	for (int c = 0; c < MAXCOL; ++c)
    		newarr[MAXROW][c] = max[c];
    
    	for (int r = 0; r < MAXROW + 1; ++r) {
    		for (int c = 0; c < MAXCOL + 1; ++c)
    			newarr[r][c] ? cout << newarr[r][c] << "\t" : cout << " \t";
    
    		cout << "\n";
    	}
    
    	{
    
    		//Function to find average of negatives
    		void case3();
    		{
    			int negNumber = 0;
    			double average = 0;
    
    			for (int r = 0; r < 6; ++r) {
    				for (int c = 0; c < 6; ++c) {
    					if (newarr[r][c] < 0) {
    						++negNumber;
    						average += newarr[r][c];
    					}
    
    				}
    			}
    			if (negNumber > 0) {
    				average /= negNumber;
    				cout << "Average of negatives: \n" << average;
    			}
    			else
    				cout << "No negatives.\n";
    
    
    		}
    
    		void case4();
    		{//Function to find product of numbers different from 0
    			int count = 0;
    			int product = 1;
    			bool f = false;
    
    			for (int r = 0; r < 6; ++r)
    				for (int c = 0; c < 6; ++c)
    					if (newarr[r][c] != 0)
    					{
    						++count;
    						product *= newarr[r][c];
    						f = true;
    					}
    
    
    			if (count != 0)
    				cout << "\n Product of numbers different from 0 is: \n" << product << endl;
    			else
    				cout << "All elements are = 0";
    
    		}
    		void case5();
    		{
    			for (int r = 0; r < MAXROW + 1; ++r) {
    				for (int c = 0; c < MAXCOL + 1; ++c)
    					newarr[r][c] ? cout << newarr[r][c] << "\t" : cout << " \t";
    
    				cout << "\n";
    			}
    		}
    	}

As you can see in case1() is the input array. What I wonder how to use this array in all other functions(case2,case3,case4,case5). 
I also define several global variables but i want to put them in the function case1().

(const int MAXROW = 5;
const int MAXCOL = 5;)

How will this happen? How to call them in the menu?

For now my error list is full with "'A': undeclared identifier".
