![]() |
|
#1
|
|||
|
|||
Two-dimensional array....is my answer right?I don't know if i understood the question correctly or not?
Is my answer right? here is the question: Write a function that initializes the components of a two-dimensional array in the following manner: components above the upper-left to lower-right diagonal should be set to 1. Those below the diagonal should get –1 and those on the diagonal should be initialized to 0. Assume the array has width and height equal to arraysize, where arraysize is a global constant. Write a short test program that calls your function and displays the resulting array. For example, a 3x3 array would be initialized to: 0 1 1 -1 0 1 -1 - 1 0 Here is my code: CPP / C++ / C Code:
Here is my Output: 1 0 0 -1 0 0 -1 -1 0 Last edited by admin : 04-Nov-2005 at 19:23.
Reason: Please insert your C code between [c] & [/c] tags
|
|||
|
#2
|
|||
|
|||
Re: Two-dimentioanl array....is my answer right?Quote:
Code:
Here is the output from your program: Code:
They don't look the same to me. Next I have a problem with your interpretation of the program specification. I would read it to mean that you have a single global constant arraysize, and you can make your program work for different arrays by changing the value of the constant. For your program you would have to rewrite the whole thing if arraysize changed from 3 to, say, 5. Regards, Dave |
|
#3
|
|||
|
|||
Re: Two-dimentioanl array....is my answer right?Hey jack223
You've been asked twice to read the guidelines by Paramesh, and the admin has corrected your posts and asked you to use code tags twice. Maybe now is the time to do it? __________________
Please read http://www.gidforums.com/t-5566.html. They were written to help you create a request that is readable and has enough information we can actually tell what you need help with. |
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 10:25 |
| Dynamic allocation of multi dimensional array | pointer | C Programming Language | 7 | 14-May-2005 00:50 |
| Array 1 dimensional help please asap | lion123 | C Programming Language | 10 | 18-Feb-2005 22:53 |
| template comiling problems - need expert debugger! | crq | C++ Forum | 1 | 01-Feb-2005 22:26 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The