• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Having problem with Array practice excises

Write a function 'identity' which returns a 1 if the array argument passed to it represents an identity matrix, and returns 0 otherwise.

An identity matrix is an m by m array of integers, where the values of the elements on the principle diagonal (row subscript == col subscript)equal 1, and all other elements are 0.

for example:

      1   0   0   0
      0   1   0   0
      0   0   1   0
      0   0   0   1

      is an identity matrix of order 4 by 4,

      1   0   0
      0   1   0
      0   0   1

      is an identity matrix of order 3 by 3,

and
      1   1   5
      0   1   0
      0   0   1

      is NOT an identity matrix.


The function identity is passed two arguments: the array, and the order of the matrix (ie the size of the two dimensions). Thus the prototype of the function would be written as:

int identity (int a[][], int m);

where a is the array and m represents the number of rows and columns.

You may assume that the number of rows always equals the number of
columns
for the array.

0
muhbest
Asked:
muhbest
1 Solution
 
Answers2000Commented:
We don't do your homework for you.  It's against EE policy.

Have a go, and post your code asking specific questions if you run into problems
0
 
pagladasuCommented:
I agree with Answer2000 - give it a try yourself and then send in your queries regarding any problems.

0
 
The_BrainCommented:
It is not that difficult.  :)  think ||. that is all I am saying.
0
 
RONSLOWCommented:
cannot be done as you cannot has a function with prototype

int identity (int a[][], int m);

the [][] doesn't work (only the last [...] can be empty


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now