zrrz, your entire 'for' loop is incorrect. Line 7 will not run at all, because you initialize i at 2, and then the condition is i<2, which is false. Also, you don't use the main advantage of bool, which is to stop the loop as soon as found becomes true.. In the end, you still won't know where 43 is, even though you know it is there...
jahanzaib ali khan Iiu, you're not allowed to post the same problem twice. You could have very well posted this doubt in your previous post as well. http://www.cplusplus.com/forum/beginner/59324/
Anyways, basically you have to do what xrrz said... Something like:
1 2 3 4 5 6 7 8 9 10 11 12
bool found=false;
for (int i=0; (i<2)&&(found==false); i++)
{
for (int j=0; (j<4)&&(found==false); j++)
{
if (arr[i][j]==43)
found=true;
}
}
cout<<"43 is at ("<<i<<", "<<j<<")"; //Prints location of 43.
Caprico, i am sorry i am new into this forum and i thought that posting twice could help me more fastly so i did that.Anyhow Thanks a lot to both Caprico and zrrz for giving me the help........