Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8350829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:26:28+00:00 2026-06-09T08:26:28+00:00

Simple, probably easy to answer question. What is the difference between || and or

  • 0

Simple, probably easy to answer question. What is the difference between || and or in something like an if statement.

Simple examples:

#include <iostream>

int main(){
    int x = 8;

    if(x == 8 or 17){
        std::cout << "Hello World!\n";
    }
}

and

#include <iostream>

int main(){
    int x = 8;

    if(x == 8 || 17){
        std::cout << "Hello World!\n";
    }
}

These seem to work the same way for me. They both compile and they both display “Hello World!” I’ve always used || and didn’t even know about or. Do they do the same exact thing? Or is there a slight difference like using \n or endl where one acts slightly different. Sorry if this is a really simple question.
Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:26:29+00:00Added an answer on June 9, 2026 at 8:26 am

    As Luchian says, there is no semantic difference. A draft of the latest C++ standard says, in the “Keywords” section:

    Furthermore, the alternative representations shown in Table 5 for
    certain operators and punctuators (2.6) are reserved and shall not be
    used otherwise:

    and     and_eq  bitand  bitor  compl   not
    not_eq  or      or_eq   xor    xor_eq
    

    But there could be a difference for anyone reading your code. The || operator for “logical or” goes back decades. The alternative representations are newer.

    They were introduced at least as early as the 1998 C++ standard (I don’t know if pre-ISO C++ had them). It’s at least conceivable that you might encounter a C++ compiler that doesn’t recognize them, but if so it’s going to be an old enough compiler that you’ll have other problems. C introduced similar identifiers in its 1995 amendment (but only with #include iso646.h>).

    At least in C, and probably in C++, these alternate representations, along with digraphs and trigraphs, were introduced to cater to systems with character sets that don’t include all the characters that would otherwise be required for C and C++:

    { } [ ] # & | ^ ~ !
    

    With the introduction of more modern character sets, particularly Unicode, such systems are increasingly rare.

    But as far as I can tell, they’re rarely used in code (I don’t think I’ve ever seen any code that uses them), and some C++ programmers might not be aware of them. I believe your code will be more legible if you use || rather than or.

    And as Luchian also says, (x == 8 || 17) doesn’t mean what you might expect from, say, English grammar. It doesn’t mean “x is equal to either 8 or 17”; it means ((x == 8) || 17); 17 is treated as a condition by itself, not compared to x. Possibly you wanted to write (x == 8 || x == 17).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

simple question, probably easy for you to answer. I have a dll named MigrationSteps.dll
This is probably a question that has an easy/simple/obvious answer, but I've found myself
This is probably a very easy question to answer, but for the life of
This is probably an easy question but I can't figure out the best answer
OK, this sounds simple and or like something that should have probably been done
I would like to ask probably simple question. Consider following php page: <p>Name of
Simple (probably stupid) question. I'm a Powershell novice and am mainly using it to
There is probably a simple answer for this, but I couldn't find one, so
Probably something simple, but heres my problem, I have implememnted a simple captcha into
This is probably a simple question but I can't seem to figure out how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.