+ 16
every element in a matrix have a unique position , ie unique index of a 2-d matrix , so u can run two loops & test whether the number u r looking for is available or not & if it is found then replace it with number u wanted to //no , there will no exchange in position of any other elements â˜ș thanks for reading , here is the code ::: //suppose matrix is of order m×n for(c=0;c<m;c++) { for(d=0;d<n;d++) { if (mtrx[c][d]==x) mtrx [c][d]==y; //x is number u r looking for & y is number u want replace it with } } //the above mentioned code will replace all x with y , but if u want to do for only 1 x , then u can put "break;" in if condition //hope it helped 😃
29th Dec 2017, 4:46 AM
Gaurav Agrawal
Gaurav Agrawal - avatar