[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Having problem with Array  practice excises

Posted on 1998-12-13
4
Medium Priority
?
165 Views
Last Modified: 2012-05-04
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
Comment
Question by:muhbest
4 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180097
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
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180098
I agree with Answer2000 - give it a try yourself and then send in your queries regarding any problems.

0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1180099
It is not that difficult.  :)  think ||. that is all I am saying.
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 200 total points
ID: 1180100
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question