Where do I locate the logical or on my keyboard? Thanks for your help in advance.

Recommended Answers

All 5 Replies

If you don't mean the logical OR operator in C, example follows, then you need to be more specific about what exactly you want to do.

#include <stdio.h>

int main ( void )
{
  if ( 0 || 1 ) /* || is the logical OR operator */
    puts ( "True" );
  else
    puts ( "False" );

  return 0;
}

Hi,

How do i type (||). In this case I used copy and paste. I cant find it on my keyboard.

Thanks

It's above the Enter key on your keyboard with '\' symbol.....................

>I cant find it on my keyboard.
Oh dear. It's the vertical bar, placed as the shift value for my backslash key, but it could be somewhere else (or not present at all) depending on the keyboard. Note that the || operator is two vertical bars, not a single key on your keyboard. If you still can't find it, you may fall into the category of C programmers that need to take advantage of C's trigraph sequences:

#include <stdio.h>

int main ( void )
{
  if ( 0 ??!??! 1 )
    puts ( "True" );
  else
    puts ( "False" );

  return 0;
}

This does the same thing as my first example, except the ??! trigraph represents the vertical bar with a combination of universal characters. Here are all of the trigraphs if you discover you're missing other keys:

??>    }
??<    {
??)    ]
??(    [
??=    #
??!    |
??/    \
??'    ^
??-    ~

Before you use them, make absolutely sure that they're necessary, as trigraphs are clearly very detrimental to the readability of your code.

Thanks, so simple. My keyboard displays ¦, however prints correct |.

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.