+ 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

9th Jan 2022, 4:32 PM
Sangeetha Santhiralingam
Sangeetha Santhiralingam - avatar
7 Answers
+ 1
No
9th Jan 2022, 4:39 PM
Sangeetha Santhiralingam
Sangeetha Santhiralingam - avatar
+ 1
Something wrong second if is not work if I enter a unknown element second if want work but here not working
9th Jan 2022, 4:39 PM
Sangeetha Santhiralingam
Sangeetha Santhiralingam - avatar
+ 1
Can you correct and put it
9th Jan 2022, 4:47 PM
Sangeetha Santhiralingam
Sangeetha Santhiralingam - avatar
+ 1
Yes šŸ„°
9th Jan 2022, 4:55 PM
Sangeetha Santhiralingam
Sangeetha Santhiralingam - avatar
0
What's wrong? It works well.
9th Jan 2022, 4:38 PM
FanYu
FanYu - avatar
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.
9th Jan 2022, 4:44 PM
FanYu
FanYu - avatar
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; }
9th Jan 2022, 4:50 PM
FanYu
FanYu - avatar