943,542 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1568
  • C++ RSS
Nov 21st, 2008
0

c++ program to find the product of two array of integers-clear errors?

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. #include<iostream.h>
  2. int main()
  3. {
  4. int row1[10];
  5. int col2[10];
  6. int m,n,p,q;
  7. cout<<"Enter the number of rows in matrix A"<<endl;
  8. cin>>m;
  9. cout<<"Enter the number of columns in matrix A"<<endl;
  10. cin>>n;
  11. cout<<"Enter the number of rows in matrix B"<<endl;
  12. cin>>p;
  13. cout<<"Enter the number of columns in matrix B"<<endl;
  14. cin>>q;
  15. if(n!=p)
  16. {
  17. int i=0;
  18. cout<<"enter the rows of matrix1"<<endl;
  19. for(i=0;i<=m;i++)
  20. {
  21. cin>>row1[i];
  22. int *ptrow= &row1[0];
  23. row1[i]= *(row1+i);
  24. }
  25. cout<<"enter the cols of matrix1"<<endl;
  26. int k=0;
  27. for(k=0;k<=;k++;)
  28. {
  29. cin>>row1[k];
  30. int *ptcol2= &col2[0];
  31. col2[k]= *(col2+k);
  32. }
  33. int matpro (int row1, int col2, int (*matpro)(int,int));
  34. {
  35. int pro[i][k];
  36. for(i=0;i<m;i++;)
  37. {
  38. for(k=0;k<=q;q++)
  39. {
  40. pro[i][k]= row1[i] * col2[k];
  41. int *ptpro= &pro[0];
  42. pro[i][k] = *(pro+i);
  43. pro++;
  44. }
  45. }
  46. cout << "[" << i << "][" << j << "]: " << pro[i][j];
  47. return(pro[i][k]);
  48. }
  49. }
  50. }

it is showing errors like

C++ Syntax (Toggle Plain Text)
  1. expected primary-expression before ‘;’ token
  2. 27: error: expected `)' before ‘;’ token
  3. 27: error: expected primary-expression before ‘)’ token
  4. :27: error: expected `;' before ‘)’ token
  5. :36: error: expected `)' before ‘;’ token
  6. :36: error: expected primary-expression before ‘)’ token
  7. :36: error: expected `;' before ‘)’ token
  8. :48: error: expected `}' at end of input
  9. :48: error: expected `}' at end of input
  10. 48: error: expected `}' at end of input
  11.  
Last edited by jbennet; Nov 21st, 2008 at 10:56 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vahny is offline Offline
3 posts
since Nov 2008
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

A) no code tags
B) this aint the C section.

Fixed. Check the rules.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

This:
for(k=0;k<=;k++;)
Should be this:
for(k=0;k<=;k++) ( no semicolon after k++)
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

Remove ';' at mathpro
C++ Syntax (Toggle Plain Text)
  1. int mathpro(int,int,int)
  2. {
  3. // math operation
  4. }
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

And here's another one, in the following snippet k stops when it is more than what? Or, if you prefer, complete the following if k is less than or equal to what:

for(k=0; k<= ; k++; )
Last edited by Lerner; Nov 21st, 2008 at 1:52 pm.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

I've modified the programlike this, but its still not working:What's probem with this function?
C++ Syntax (Toggle Plain Text)
  1. int matpro(int row1[i],int col2[k],int pro[i][k]);
  2. pro[i][k] += pro[i][k]+ (*matpro)(&row1[i],&col2[k]);
  3. cout << "[" << i << "][" << k << "] " << pro[i][k];
  4. return(pro[i][k]);
  5. void matpro(int row1, int col2, int (*matpro)(int &row1,int &col1));
Last edited by Ancient Dragon; Nov 21st, 2008 at 11:20 pm. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vahny is offline Offline
3 posts
since Nov 2008
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

The semicolon are removed, but errors exist in the function defintion.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vahny is offline Offline
3 posts
since Nov 2008
Nov 21st, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

Vahny, this is your last chance. I told you before to USE CODE TAGS.
Click "Member Rules" and its all explained in there
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
Nov 22nd, 2008
0

Re: c++ program to find the product of two array of integers-clear errors?

So what's the problems. Declare the method before using them..Example..
// CODE TAG
//   
C++ Syntax (Toggle Plain Text)
  1.  
  2. // your code here
  3. //
void matpro(int,int,int); void main() { // call matpro matpro(1,2,3); } void matpro(int a,int b, int c) { // implm. here }
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: How set fullscreen under win 2000 pro(console)?
Next Thread in C++ Forum Timeline: hpp?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC