Print boundry value

#include <iostream>

using namespace std;
const int MAX = 100;

void pritnBoundry(int arr[][MAX], int m, int n){
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            if(i==0 || j==0 || i == n-1 || j == n-1){
                cout<<arr[i][j]<<" ";
            }
            else{
                cout<<" "<<" ";
            }
        }
        cout<<endl;
    }
}

int main(){
    int arr[4][MAX] = {{1,2,5,8},
                       {2,5,2,6},
                       {8,6,9,4},
                       {7,9,5,6}};
    pritnBoundry(arr,4,4);

    return 0;
}

    Leave a Reply

    Your email address will not be published.

    Need Help?