+ 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

29th Dec 2017, 2:01 PM
zahra
zahra - avatar
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.
29th Dec 2017, 2:15 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 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.
29th Dec 2017, 2:16 PM
Akash Pal
Akash Pal - avatar