+ 1
Why else is not work of my coding and I want last cout only . anyone explain it what is the wrong
Search the element and replace it one or more place want replace if this array has 3 zeros Want to replace all zeros in a line . https://code.sololearn.com/cQkum70mou8W/?ref=app
7 Respuestas
+ 1
No
+ 1
Something wrong second if is not work
if I enter a unknown element second if want work but here not working
+ 1
Can you correct and put it
+ 1
Yes 🥰
0
What's wrong? It works well.
0
Maybe you can delete the do while, since the for statement is enough, and replace the i of the second for to j or other.
0
#include<iostream>
using namespace std;
int main()
{
int array[8]={2,0,0,0,2,1,8,4};
int i,j,search,replace;
bool found;
cout<<"Enter the element to search\n";
cin>>search;
cout<<"Enter the element to replace\n";
cin>>replace;
for(i=0;i<8;i++)
{
if(search==array[i])
{
found=true;
cout<<"\n PRESENT\t";
array[i]=replace;
for(j=0;j<8;j++)
{
cout<<array[j]<<"\t";
}
cout<<endl;
}
}
if(found==false)
{
cout<<"\nNOT PRESENT";
}
return 0;
}