Neither the while loop is working nor do while | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Neither the while loop is working nor do while

The output says time limit exceeded #include <iostream> using namespace std; int main() { cout<<"Are you satisfied with the result?"<<endl; char m; cin>>m; // cout<<m<<endl; // do { while(!(m=='y')||!(m=='n')) { if (m=='y') { cout<<"Thanks for your feedback" ; } else if(m=='n'||m=='N') { cout<<"I'll try to improve" ; ; } else { cout<<"try again"; } } // while(!(m=='y')); // ||(m=='n')); return 0; }

24th Jun 2016, 7:32 AM
Divyanshu Bhatnagar
Divyanshu Bhatnagar - avatar
3 Answers
+ 3
try this: while(1) { cin>>m; if (m=='y'||m=='Y') { cout<<"Thanks for your feedback" ; } else if(m=='n'||m=='N') { cout<<"I'll try to improve" ; } else { cout<<"try again"; } }
10th Nov 2016, 8:02 PM
Omkar Kirpan
Omkar Kirpan - avatar
+ 1
your while is always true so in if and in else if statement non is true that is why u getting no ans.
24th Jun 2016, 8:50 AM
Chirayu Barde
Chirayu Barde - avatar
0
try && instead of || in the while condition.
26th Jun 2016, 7:27 PM
Garme Kain
Garme Kain - avatar