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

Reply

Join Date: Nov 2008
Posts: 3
Reputation: vahny is an unknown quantity at this point 
Solved Threads: 0
vahny vahny is offline Offline
Newbie Poster

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

 
0
  #1
Nov 21st, 2008
  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

  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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,955
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 504
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

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

 
0
  #2
Nov 21st, 2008
A) no code tags
B) this aint the C section.

Fixed. Check the rules.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,752
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 294
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Maven

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

 
0
  #3
Nov 21st, 2008
This:
for(k=0;k<=;k++;)
Should be this:
for(k=0;k<=;k++) ( no semicolon after k++)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

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

 
0
  #4
Nov 21st, 2008
Remove ';' at mathpro
  1. int mathpro(int,int,int)
  2. {
  3. // math operation
  4. }
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,671
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

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

 
0
  #5
Nov 21st, 2008
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.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: vahny is an unknown quantity at this point 
Solved Threads: 0
vahny vahny is offline Offline
Newbie Poster

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

 
0
  #6
Nov 21st, 2008
I've modified the programlike this, but its still not working:What's probem with this function?
  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
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: vahny is an unknown quantity at this point 
Solved Threads: 0
vahny vahny is offline Offline
Newbie Poster

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

 
0
  #7
Nov 21st, 2008
The semicolon are removed, but errors exist in the function defintion.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 15,955
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 504
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

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

 
0
  #8
Nov 21st, 2008
Vahny, this is your last chance. I told you before to USE CODE TAGS.
Click "Member Rules" and its all explained in there
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

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

 
0
  #9
Nov 22nd, 2008
So what's the problems. Declare the method before using them..Example..
// CODE TAG
//   
  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 }
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC