i know that the AND command is && but what are the code for OR? also if i have a program looping through a system and i want to add something to a variable each time through would

ERRORtotal += ERR1

work? or wat would

Member Avatar for iamthwee

Or = ||

>ERRORtotal += ERR1

That would work.

would this work.

if ( pattern1 || pattern2 == 1 )

does this mean that if either pattern1 or pattern2 is 1 then it will do what comes in that set of brackets.

because ive done this

cout << " please select which 2 patterns you want to be learned" << endl;
cin >> pattern1;
cin >> pattern2;

if ( pattern1 || pattern2 == 1 )
{
    cout << endl << "pattern1 is " << '\1' << " -- 1" << endl << setw(13) << '\1' << " -- 1"; 
}
    
if ( pattern1 || pattern2 == 2 )
{
    cout << endl << endl << "pattern2 is " << '\2' << " -- 0" << endl << setw(13) << '\2' << " -- 0";
}   
 
if ( pattern1 || pattern2 == 3 )
{ 
    cout << endl << endl << "pattern3 is " << '\1' << " -- 1" << endl << setw(13) << '\2' << " -- 0";
}   

if ( pattern1 || pattern2 == 4 )
{
    cout << endl << endl << "pattern4 is " << '\2' << " -- 0" << endl << setw(13) << '\1' << " -- 1";
}

but when i put two numbers in, one for each pattern then it just shows all 4 of them

Member Avatar for iamthwee

Maybe

Test1

#include <iostream>
#include <string>

using namespace std;

int main()
{
   int pattern1 = 0;
   int pattern2 = 0;
   
   if  (pattern1 == 1 || pattern2 == 1 )
   {
        cout << "Accepted";
   }
   cin.get();
}

test2

#include <iostream>
#include <string>

using namespace std;

int main()
{
   int pattern1 = 1;
   int pattern2 = 0;
   
   if  (pattern1 == 1 || pattern2 == 1 )
   {
        cout << "Accepted";
   }
   cin.get();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.