boolean operator "or"

This is a discussion on boolean operator "or" within the C++ Programming forums, part of the General Programming Boards category; Hi I am obviously new to c++. I can't figure out how you type in the boolean operator "or." Which ...

  1. #1
    UpTooLate
    Join Date
    Feb 2008
    Location
    New York
    Posts
    32

    Question boolean operator "or"

    Hi I am obviously new to c++. I can't figure out how you type in the boolean operator "or." Which keys is it on the keyboard???

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Depends on your keyboard layout, which in turn depends on which "language" the keyboard is set up to use.

    You can get the same "character" by holding down ALT and typing 124 on the numeric part of the keyboard.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Amyaayaa View Post
    Hi I am obviously new to c++. I can't figure out how you type in the boolean operator "or." Which keys is it on the keyboard???
    The operator is ||. The character you are looking for is the vertical bar. I have used Russian, Hebrew, and US keyboards and on all of those, the symbol is on the same key as backslash. I don't know about other keyboards.

    Or, you can simply use the word "or" which means the same thing, in C++ only.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Use two pipe characters: ||
    On a standard US keyboard it's usually shift + '\' above the enter key.

    If your keyboard doesn't have a | key, you could always include <ciso646> and use "or" instead of "||".
    http://en.wikipedia.org/wiki/Iso646.h

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    On a German keyboard, you get the key using AltGr+<.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by cpjust View Post
    Use two pipe characters: ||
    On a standard US keyboard it's usually shift + '\' above the enter key.

    If your keyboard doesn't have a | key, you could always include <ciso646> and use "or" instead of "||".
    http://en.wikipedia.org/wiki/Iso646.h
    No need to include that file as it part of the C++ standard already.

  7. #7
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Thantos View Post
    No need to include that file as it part of the C++ standard already.
    Then why would they bother having a <ciso646> for us to include to begin with?

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,647
    Then why would they bother having a <ciso646> for us to include to begin with?
    I have no idea. The header seems completely redundant. A check of the MinGW port of g++ 3.4.5 reveals a <ciso646> header file that consists entirely of comments.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Well, those words are keywords already under the current C++ standard. The header is in fact part of the C95 standard that got added to C++ in 98 for reasons of consistency. There is indeed no need to add it under C++.
    Last edited by Mario F.; 02-15-2008 at 10:41 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    UpTooLate
    Join Date
    Feb 2008
    Location
    New York
    Posts
    32
    thank you, that is what I was looking for!

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Mario F. View Post
    The header is in fact part of the C95 standard that got added to C++ in 98 for reasons of consistency.
    You mean C99?

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Quote Originally Posted by cpjust View Post
    Use two pipe characters: ||
    On a standard US keyboard it's usually shift + '\' above the enter key.

    If your keyboard doesn't have a | key, you could always include <ciso646> and use "or" instead of "||".
    http://en.wikipedia.org/wiki/Iso646.h
    . . . or use trigraphs, though you'd probably have to enable them in your compiler options first.

    But don't use trigraphs unless you have to, because they can cause problems and look weird.

    [edit]
    > C95
    You mean C99?
    I was going to mention that too . . . C95 was what the standard used to be called when no one knew when the standard would actually finalize, AFAIK. It's generally called C99 now. [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    That's it then. Thanks for the correction. I had it edited from C99 to C95 when I saw the copyright on my header file. Didn't know C95 was just a moniker.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Hmm ... isn't C95 like C++03, the date of a technical corrigendum?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #15
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    It's possible yes because I do remember reading somewhere about iso646.h being added to the standard about that time - and not by C99 as the wikipedia article provided by cpjust reads.

    My memory is not to be trusted though. However, gcc iso646.h copyright is dated 1997

    EDIT: just confirmed with the cvs (old-gcc) and the file there is 12 years and 8 months old, dated June, 15 1995.
    Last edited by Mario F.; 02-15-2008 at 07:11 PM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Novice needs help
    By ghaasemi in forum C++ Programming
    Replies: 9
    Last Post: 05-30-2009, 08:20 AM
  2. Casting boolean as string
    By doofusboy in forum C Programming
    Replies: 11
    Last Post: 11-10-2005, 11:24 AM
  3. Replies: 4
    Last Post: 04-02-2004, 06:30 PM
  4. Working with boolean...
    By CompiledMonkey in forum C Programming
    Replies: 4
    Last Post: 11-03-2003, 09:39 AM
  5. Use struct to create a boolean type
    By skyglin in forum C Programming
    Replies: 6
    Last Post: 06-18-2003, 08:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21