![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2008
Posts: 3
Rep Power: 0
![]() |
I need help in writting pseudocode
Am really embarrasingly new to C/C++, a good thing you cant see me otherwise I wouldnt post here. Okay the thing is I got this book called C language by o relly, I didnt find it simple to understand. Our lecturer later gave us an assignment to code in C or C++ a program that multiplies two matrices m by n (no specific matrix size) and gives the output so I came up with this:
c Syntax (Toggle Plain Text)
Like l said am new to this, so bear with me here. I wanted to know how to write its pseudocode, I developed a habbit of writting the code before the pseudocode. Now I need help in writting the pseudocode before the code. Am asking this because I failed in writting one. Can anyone help? If you dont mind I would appreciate I anyone can help me make it work.Its giving me an undefined A[m][n] error. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
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:
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?
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 228
Rep Power: 3
![]() |
Re: I need help in writting pseudocode
Quote:
For example the following code is valid:
int foo(int len)
{
int vla[len];
for (int i = 0; i < vla[len]; i++)
vla[i] = i;
for (int i = 0; i < vla[len]; i++)
printf("%i\n", vla[i] = i);
}Of course VLA operands will cause problems when compiled with C++. As you mentioned you could use C or C++, you may want to consider moving to a compiler that will support C99. of course you must also make sure that the expression you are using to specify the size of the array is defined first . |
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
Re: I need help in writting pseudocode
Yes, but until C99 is standard (not to mention completely compliant *points at GCC*) across all compilers, let's try not to confuse the original poster, or rely on specific features when more reliable alternatives exist?
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#5 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 646
Rep Power: 4
![]() |
Re: I need help in writting pseudocode
I agree with Sane here, but C99 is pretty neat. How long has it been? 9 years? GCC should really get on adding missing support (especially the complex numbers and tgmath.h).
EDIT: A lot is actually missing. http://gcc.gnu.org/gcc-4.3/c99status.html
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Mar 2008
Posts: 3
Rep Power: 0
![]() |
Re: I need help in writting pseudocode
@Sane "I'd recommend putting an upper-boundary on how large the matrix can be"
int A[m] [n]; int B[k] [l]; int C[t] [u]; Giving an upper boundary on how large would fail the question because the question asked of m by n size (no boundaries) actually these are meant to be arrays defined during the running of the program not before the program begins. Am sure am missing some kind of library reference or some kind of inclusion so that it may actually be arrays whose size is determined by the user ** Guys I made a mistake I should have posted this in C language not C++. Can this be transfered to the C section? ** Am using visual c++ 6.0 to code in c language |
|
|
|
|
|
#7 |
|
PFO Founder
![]() ![]() |
Re: I need help in writting pseudocode
Moved
![]()
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#8 | ||
|
Programming Guru
![]() ![]() |
Re: I need help in writting pseudocode
Quote:
Think of it this way: your computer does not have enough memory to handle a 1,000,000 x 1,000,000 matrix. Thus, the user can not enter 1,000,000. Therefore, there is an obvious restriction on the size. This restriction is your upper-boundary, and in the event that the user enters a very large number, it will have to be enforced one way or another in order to prevent the program from crashing. My suggestion of creating an upper-boundary, always making the array that large, and then only using the values within the inputted sizes-- is the easiest way to handle everything in one fell swoop. Quote:
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
||
|
|
|
|
|
#9 | |
|
Newbie
Join Date: Mar 2008
Posts: 3
Rep Power: 0
![]() |
Re: I need help in writting pseudocode
Thanks
Quote:
![]() |
|
|
|
|
|
|
#10 |
|
Newbie
Join Date: Apr 2005
Location: NC,USA
Posts: 17
Rep Power: 0
![]() |
Re: I need help in writting pseudocode
Writing pseudocode is worth a couple chapters of its own... I have a programming logic book I'll sell you cheap. Simple Program Design : A step-by-Step Approach Fifth Edition.
Its usualy a prerequisite to any actual programming class. Last edited by jamesdman; Apr 25th, 2008 at 11:00 AM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flow chart and pseudocode assignment | JimR | Other Programming Languages | 19 | Nov 9th, 2008 9:26 PM |
| tips for writingh pseudocode | redux | Software Design and Algorithms | 2 | Sep 23rd, 2007 7:23 PM |
| Pseudocode | Hass | Java | 6 | Nov 22nd, 2005 2:18 PM |
| urgent pseudocode | faceboy62 | Visual Basic | 10 | Nov 15th, 2005 5:07 PM |
| Pseudocode Help | Rob.K | Other Programming Languages | 2 | Mar 15th, 2005 3:42 AM |