+ 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; }
3 Réponses
+ 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";
     }
   }
+ 1
your while is always true so in if and in else if statement non is true that is why u getting no ans.
0
try && instead of || in the while condition.



