Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 2nd, 2008, 6:42 AM   #1
Magneto Delta
Newbie
 
Join Date: Mar 2008
Posts: 3
Rep Power: 0 Magneto Delta is on a distinguished road
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)
  1. // program to multiply 2 matrices ( A and B or M by N of rows and columns defined by the user)
  2. # include <stdio.h>
  3. int main ()
  4. { int d,i,j,k,l,m,n,p,q,t,u,x ;
  5.  
  6. int A[m] [n];
  7. int B[k] [l];
  8. int C[t] [u];
  9.  
  10. i=0; d=0; j=0; j=0; k=0; l=0; m=0; n=0; n=0; p=0; q=0; t=0; u=0; x=0;
  11.  
  12. /* Entre the size of the matrices A and B */
  13.  
  14. printf (" Entre no. of rows for 1st matrix : \n");
  15. scanf (" %d", &m );
  16. printf (" Entre no. of rows for 1st matrix : \n");
  17. scanf (" %d", &m );
  18. printf (" Entre no. of rows for 2nd matrix : \n");
  19. scanf (" %d", &p );
  20. printf (" Entre no. of columns for 2nd matrix : \n");
  21. scanf (" %d", &q );
  22.  
  23. /* Entre the values of the matrices */
  24.  
  25. printf (" Entre values for 1st matrix from 1st row,1st col integer to the right end then 2nd row, 1st col to the right end.... : \n");
  26.  
  27. while ( i<m)
  28. { while ( j<n)
  29. { printf (" A[%d] [%d] = ? :" , i,j );
  30. scanf ("%d", &A[i] [j] ); ++j; } j=0 ; ++i}
  31.  
  32. printf (" Entre values for 2nd matrix from 1st row,1st col integer to the right end then 2nd row, 1st col to the right end.... : \n");
  33.  
  34. i=0;j=0
  35.  
  36. while (i<p)
  37. { while (j<q)
  38. { printf (" B[%d] [%d] = ? :" , i,j );
  39. scanf ("%d", &B[i] [j] ); ++j; } j=0 ; ++i}
  40.  
  41. i=0; j=0;
  42.  
  43. /* Calculate the product of matrix A and matrix B */
  44.  
  45. while (k<p)
  46. { while ( i<m)
  47. { while (j<n)
  48. { C[t] [u]+=A[i] [j]*B[k] [l] ;
  49. ++j ; ++k ; }
  50. ++i ; ++t ; k=0 ; j=0 ; }
  51. t=0 ; ++u ; i=0 ; j=0 ; ++l ; k=0 ; }
  52.  
  53.  
  54. t=0; u=0;
  55.  
  56. /* Read out the values of the obtained matrics C */
  57.  
  58. while (t<x)
  59. { while (u<d)
  60. { printf (" C[%d] [%d] = %d\t\t",t,u, C[t] [u]) ; }
  61. printf ("\n") ;
  62. ++u ; }
  63. u=0 ; ++t ; }

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.
Magneto Delta is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC