c++ - Why doesn't this code compile -
#include <iostream> #include<iomanip> using namespace std; int main() { const int numrows=3; const int numcols=4; int i,j; int val[numrows][numcols]={8,16,9,52,27,6,14,25,2,10};//multiply each element 10 , display cout<<"\ndisplay or multiplied elements"; for(i=0; i<numrows;i++) { val[i][j]=val[i][j]*10; }//end of inner loop }//end of outer loop cout<endl; return 0; }
these errors received. have done wrong 16:5: error: 'cout' not name type 17:5: error: expected unqualified-id before 'return' 18:5: error: expected declaration before '}' token
you're missing inner loop , cout after double loop missing second carrot. should this:
int main() { const int numrows=3; const int numcols=4; int i,j; int val[numrows][numcols]={8,16,9,52,27,6,14,25,2,10};//multiply each element 10 , display cout<<"\ndisplay or multiplied elements"; for(i=0; i<numrows;i++) { for(j=0; j<numcols;j++) { val[i][j]=val[i][j]*10; }//end of inner loop }//end of outer loop cout<<endl; return 0; }
Comments
Post a Comment