View Single Post
Old Mar 2nd, 2008, 7:25 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,888
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: I need help in writting pseudocode

The biggest problem is this part here:

int A[m] [n];
int B[k] [l];
int C[t] [u];

There are two problems with this:
  1. The value of m, n, k, l, t, and u, are all undefined at this point in the program. Remember that programs execute in steps, and variables are in a way "replaced" with their value each time they are referenced. Thus, m, n, k, l, and t, all "replace" the array sizes with their values at that time. Since none of those variables have even been given a value yet, random junk is substituted instead.
  2. When you are declaring an array, if you need to make the size dynamic (dynamic size is when the program does not yet know the size until after it has been compiled), then you need to use some other techniques such as "malloc" or "new".

I'd recommend putting an upper-boundary on how large the matrix can be. Then simply make the array that large.

#define MAX 100

int main() {
    int A[MAX] [MAX]; 
    int B[MAX] [MAX]; 
    int C[MAX] [MAX];

Look up "for loops" in your book, or online. All of your while loops should be replaced by for loops. It would make this much easier for you.

Psuedocode won't help much in this instance, since you seem to have the general idea down. You just don't yet know how to code, right?
Sane is online now   Reply With Quote