43. Write a program to read in a 5×5 matrix and then ask for an input of a number and search its position in the matrix. If found, print the indices where it is found, otherwise print “Not Found”.
Answers
#include<iostream>
#include<stdlib.h>
using namespace std;
int main () {
int flag = 0 ;
int num,arr[5][5] ;
cout<<"* Enter your array elements:\n" ;
for(int i=0; i<5;i++){
for(int j=0; j<5 ;j++){
cin>>arr[i][j] ;
}
}
cout<<"\n* Enter a number to search in the array: ";
cin>> num ;
for (int i=0;i<5 ; i++ ){
for(int j=0 ; j<5 ;j++ ){
if(num==arr[i][j]) {
cout<<"\n** Element found and with index ( " <<i<<", " <<j <<" ) ." <<endl;
flag = 1 ;
exit(0) ;
}
}
}
if( flag == 0 ){
cout<<"\n** Element not found." <<endl;
}
return 0;
}
Please mark this answer as Brainliest answer!