Exercise 3: Making Matrix Using Arrays

Let's display a matrix of zeros and ones by using a two-dimensional array.

Problem Statement

In this exercise, you have to write a function display that takes an integer size, creates a 2-D matrix of this size, and display this matrix.

  • The diagonal of the matrix should be filled with 0.

  • The lower side from the diagonal should be filled will -1s.

  • upper side from the diagonal should be filled with 1s.

Sample input

Create a free account to access the full course.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy