+ 2
Why my code not correct run?
#include<iostream> using namespace std; int main() { int i, j, n, m; cout « "please enter two numbers="; cin » n » m; int a[m][n]; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { a[i][j] = 1; } cout « "a[i][j]=" « endl; } return 0; } i want a code write 1 in every arrey
2 Answers
+ 9
The symbols after cin and cout are wrong. Use << for cout and >> for cin.
Also change a[m][n] into a[n][m], if n is your number of rows.
+ 4
First of all, update your code because no one use « . We use << this for the cout and >> for the cin. This is your first error in your code.
If you wanted to print the array values why are you using "" it makes it string and if you wanted to add both then use :-
cout << "a[i][j] = " << a[i][j] << endl;
Check and correct it.
If want to ask more comment then.