0

Multidimensional Arrays Movie tickets

I know it's wrong but I don't know what to change to really have it right. The result is correct but I know that I just got an alternative way. How can I change an 0 to an 1? It's Practise 8.2. #include <iostream> using namespace std; int main() { int rows = 6; int cols = 6; float matrix[rows][cols] = { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, }; // your code goes here for(int r=0;r < 6; r++){ for(int c=0; c<6; c++){ if(matrix[r][c]=1){ cout << matrix[r][c]; } } cout << endl; } return 0; }

10th Jan 2021, 2:28 PM
Leon Müller
3 Respuestas
+ 4
Leon Müller just remove " if () ". Hope this helps you https://code.sololearn.com/cJ29gc5Hp3pc/?ref=app Note : remember this point " if " statement is used for condition checking not for assigning values .
10th Jan 2021, 2:37 PM
NavyaSri
NavyaSri - avatar
+ 2
Leon Müller yes ,it's possible with if statement . Your english is not bad I can understand.
10th Jan 2021, 5:29 PM
NavyaSri
NavyaSri - avatar
0
But what if I had for example a 4 in the 3rd row 2nd column. Is it possible to search for it with an if statement and then change the 4 to anything else ? Shouldn't that be the right move ? Not just declare everything to 1. Hope you can understand, my English is not the best.
10th Jan 2021, 4:50 PM
Leon Müller