Condition : i need data.size() to be either divisible by 2 or 3 and greater than 0,
can't understand why my solution here ain't working, yet i think i have done it right.
1 2 3 4 5 6 7 8 9 10
while((data.size()%2!=0&&data.size()%3!=0)&&data.size()>0)
{
std::cout<<"\n\tAdd data : ";std::cin>>data;
}
///note : using (data.size()%2!=0||data.size()%3!=0) doesn't work either because
/// true||false== true meaning that it would require both %2!=0 and %3!=0 to be satisfied
//for - (data.size()%2!=0&&data.size()%3!=0)
/// it also requires that both conditions be satisfied if am right
I believe that this one is the only one of it's kind, it's so confusing,what do you think should be done.
thanks.
Ooh i forgot to mention data is a string variable used to hold character sequences where the size of those sequences in required before evaluation, sorry.
The result of data.size()%2!=0 is true when data.size() is not divisible by 2 and that is the required condition for the loop to run. The same applies to data.size()%3!=0.
If you're unsure whether to use && or ||. 'and' excludes while 'or' includes:
1,2,3 and 3,4,5 -> 3
1,2,3 or 3,4,5 -> 1,2,3,4,5
To figure out the behavior you may simulate what a certain expression or a combination thereof does: