-7
#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 by 10 and display it 
    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 are the errors I received. What have I done wrong 16:5: error: 'cout' does not name a type 17:5: error: expected unqualified-id before 'return' 18:5: error: expected declaration before '}' token

laurisvr
  • 2,724
  • 6
  • 25
  • 44
Sunny
  • 99

5 Answers5

2

You're missing your inner for loop and your cout after the double for loop is missing a second carrot. Should probably look something like 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 by 10 and display it 
    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; 
}
1

There are two issues here:

}//end of outer loop
cout<endl; 

First, while your comment says "end of outer loop", the brace actually closes main, so the code is incorrect. That is why you're getting the error on cout doesn't name a type.

Once you delete that brace, you'll get a huge compile error starting with:

error: no match for ‘operator<’ in ‘std::cout < std::endl

because you wrote cout < endl; when you meant cout << endl;

Barry
  • 286,269
  • 29
  • 621
  • 977
1

Typos:

  cout<endl; 

You have a missing < It should have been:

 cout<<endl; 

Place the above inside main, currently it is outside the scope of main.

Other issues:

 val[i][j]=val[i][j]*10;

j here is uninitialized.

  }//end of outer loop

You haven't defined any outer for loop.

Ayushi Jha
  • 4,003
  • 3
  • 26
  • 43
1

I believe you are missing a for loop for the j index:

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

Also note that you missed a < character cout<endl; should be cout<<endl;

Jérôme
  • 8,016
  • 4
  • 29
  • 35
0

It does not compile because it is not a valid C++ program.

One problem is that you have more closing brackets than opening ones. I would suggest to use a source code editor that indicates what bracktes belong to each other.

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185