I don't know what I missed but it seems like my loops just go on with out stopping.
This is the question:
Suppose we want to input and validate three characters in a do..while loop. The variable names are c1, c2 and
c3. The values of c1 and c2 may not be the same and c3 may not be equal to X. If this condition does not hold, the
loop has to be executed again. Write down a correct condition for the do..while loop.
My coding:
#include <iostream>
using namespace std;
int main()
{
char c1,c2,c3;
do
{
cout<<"Enter a character:";
cin>>c1;
cout<<"Enter a second character:";
cin>>c2;
cout<<"Enter a third character:";
cin>>c3;
} while ((c3 = 'X') or (c1 = c2));
return 0;
}
I can't see the problem here guys.
This is the question:
Suppose we want to input and validate three characters in a do..while loop. The variable names are c1, c2 and
c3. The values of c1 and c2 may not be the same and c3 may not be equal to X. If this condition does not hold, the
loop has to be executed again. Write down a correct condition for the do..while loop.
My coding:
#include <iostream>
using namespace std;
int main()
{
char c1,c2,c3;
do
{
cout<<"Enter a character:";
cin>>c1;
cout<<"Enter a second character:";
cin>>c2;
cout<<"Enter a third character:";
cin>>c3;
} while ((c3 = 'X') or (c1 = c2));
return 0;
}
I can't see the problem here guys.