text:
Compare two integers in C or C++ without comparison operators
Produce the shortest program which takes two signed integers as input (through stdin or as arguments) and displays 3 different outputs depending upon whether the first number is (1) greater than, (2) smaller than, or (3) equal to the second number.
The Catch
You cannot use any of the following in your program:

The standard comparison operators: <, >, <=, >=, ==, !=.
Any library file apart from conio, stdio, or iostream.
Any non-ASCII or non-printable ASCII character.

The Winner
The program with the shortest number of characters wins.

I suppose using things like abs without including the library file (because the compiler knows it anyway) isn't allowed either?

@MartinBüttner yes, that would be a correct assumption. :)

Why the restriction to C(++)? If it's because you want answers to be portable despite the unportability of C's basic types then you should state that. If it's an arbitrary restriction then you should be aware that arbitrary restrictions to one language are unpopular on this site.

@PeterTaylor it's part of the challenge. It would be a very different ballgame altogether if the question was language-agnostic. Restricting it to C/C++ changes the strategies used when approaching the problem. I recognize the need for questions to be open to most languages to promote participation by more people, but in this particular problem the restriction to C/C++ and their specific operators and methods is an integral part of the challenge.

Is the ternary operator allowed?

@EvilTeach yes; if anything is not explicitly forbidden in the question, then it is permitted.

53 bytes
main(a,b){scanf("%d%d",&a,&b);printf("%ld",0l+a-b);}

Only the first character of the output is relevant. The three different outputs are:

'-' if b > a
'0' if a == b
any other character if a > b

It works for the full input range of int on all platforms where sizeof(long) > sizeof(int).
Edit: it costs one extra character to make case 3 print a '+' uniquely instead:
main(a,b){scanf("%d%d",&a,&b);printf("%+ld",0l+a-b);}

90 bytes
If we can use stdio, why not use its formatting capabilities to perform comparison?
main(a,b){scanf("%d%d",&a,&b);snprintf(&a,2,"%d",b-a);a&=63;putchar(51-!(a-45)-!!(a-48));}

Assumes ASCII-compatible encoding and little-endianness.
72 bytes
Quotients are rounded toward zero but right-shifts are (in practice) "rounded down". That's a dead giveaway.
main(a,b){scanf("%d%d",&a,&b);a-=b;putchar(a?a|=1,a/2-(a>>1)?60:62:61);}

65 79 bytes
Another distinguishing property of negative numbers is that they produce negative modulo.
This one doesn't depend on integer representation at all; it even works on my 8-bit excess-127 toaster!
Oh, and since we can use conio, why not save two bytes with putch? Now, if I could only find my copy of TurboC...
main(a,b){scanf("%d%d",&a,&b);long long d=a;d-=b;putch(d?d|=1,d%2-1?60:62:61);}

EDIT: Handle large differences assuming long long is wider than int.

I'm pretty sure you need a delimiter between the %ds in your scanf to unambiguously parse two integers. Nice idea though!

@Martin: Well, it works with GCC, but I'm really not sure if it's bona fide.

What I mean is, how do you distinguish between inputs a = 1, b = 23 and a = 12, b = 3. Wouldn't you need to put 123 on STDIN in either case?

Like I said, it seems to work (with 1 23 and 12 3 as inputs).

Ohhh, you do include spaces in the input. Yeah I'm not surprised that works, actually.

Maybe I'm missing something in the rules, but...
81 bytes
main(a,b){scanf("%d%d",&a,&b);long long l=a;l-=b;printf("%lld%d",--l>>63,l>>63);}

Ouputs 00 if a > b, -10 if a == b, and -1-1 if a < b.

As common as this sort of code is, C doesn't guarantee it works. long long could be more than 64 bits, int could be as large so you could overflow, the result of right shifting negative values is implementation defined. Pretty much all C-derived answers have similar issues.

@YannVernier: Understood. I'm guessing a 100% foolproof solution would be a monster, since the only thing we could do safely (i.e. without shifting or overflow) is bit twiddling, and to do that safely we'd need to determine the length of the operands using sizeof.

64 61 characters
main(a,b){scanf("%d%d",&a,&b);for(a-=b;a/2;a/=2);putchar(a);}

Prints the character values of -1, 0, and 1 for less than, equal to, or greater than, respectively.
This implementation relies on undefined behavior for b being of type int and for inputs outside the range INT_MIN / 2 to INT_MAX / 2. On platforms where signed overflow wraps around, whether 2s-complement (basically all of them) or sign-magnitude, it will fail for 25% of possible pairs of valid int. Interestingly (to me anyway), it will work correctly on platforms where signed overflow saturates.

This won't work if a-b overflows.

Sadly that is true, but I could not think of any platform agnostic way to avoid this without comparison operators. The question does not specify a range of inputs for which results must be valid. This answer is guaranteed by the standard to work for all inputs between -(2^14) and 2^14 - 1 on all compliant platforms, and it will probably work for a substantially larger range on most platforms. All the other answers at this point make assumptions about size of type, relative sizes of types, or representation.

The question says two signed integers as input, so I'd say it has to work for all pairs. main(a,b) is already undefined behavior, so none of the answers is guaranteed to work. Nevermind portability.

You're absolutely right regarding the undefined behavior, so my implementation really doesn't guarantee anything by the standard. I'll add a note indicating what its limitations are.

 59   54 characters
54 charcters with a compiler like gcc which doesn't balk at main(x,y):
main(x,y){scanf("%d%d",&x,&y);y-=x;putchar(y>>31|!y);}

59 characters otherwise:
main(){int x,y;scanf("%d%d",&x,&y);y-=x;putchar(y>>31|!y);}

Output:

ASCII code 0x00 if x < y
ASCII code 0xFF if x > y
ASCII code 0x01 if x == y

I can assure you, main(x,y) works in gcc, so feel free to drop those 5 bytes from your character count.

main(x,y) doesn't work on my gcc.  Maybe a compiler option is required.  But you can replace main(x,y) by x;main(y).

66 102 bytes
main(a,b,c,d,e){scanf("%d %d",&a,&b);e=1<<31;c=a&e;d=b&e;putchar(a-b?c&~d?48:d&~c?49:a-b&e?48:49:50);}

Reads the integers from STDIN and prints 0 (a < b), 1 (a > b) or 2 (a == b).
Edit: Now it should also work for differences which are too large to fit into a 32-bit integer. I'm sure That nested ternary can be shortened with some more bit-magic.

Correct me if I'm wrong, but I'm seeing a<0 in your inner ternary.

@overactor fixed

52 bytes
Sadly this one only works for positive integers, but I thought the concept of using purely arithmetic operators was interesting:
main(a,b){scanf("%d%d",&a,&b);putchar(b%a/b-a%b/a);}

Outputs:

ASCII code 0xFF: a less than b
ASCII code 0x00: a equal to b
ASCII code 0x01: a greater than b

If you're going only for positive integers, putchar(a/b-b/a) is a lot shorter.

@Dennis that produces different outputs for example for (50,1) and (51,1).  But I was able to shorten a bit though.

Yes, wasn't thinking properly...

66 bytes
main(a,b){scanf("%d%d",&a,&b);putchar((0l+b-a>>63)-(0l+a-b>>63));}

Prints the byte 0x00 if a == b, 0x01 if a < b and 0xff if a > b.
Since non-ASCII or non-printable ASCII character in [my] program and if anything is not explicitly forbidden in the question, then it is permitted, unprintable character in the output should be completely fine.

My previous version didn't handle overflow very well. This works on x64 Linux, where long is 64-bits.

87 characters
main(a,b,c){scanf("%d%d",&a,&b);c=1<<31;a+=c;b+=c;puts(a^b?(unsigned)a/b?">":"<":"=");}

Using the 2^31 trick to convert to unsigned int's
Casting the division to unsigned to handle the upper bit as data, not sign
Using ^ to XOR a and b, when they are equal this returns 0
Using nested conditionals (?) to get "<",">", or "=" to feed to puts()

In 64 chars without stdio.h
a,b;main(){scanf("%d%d",&a,&b);puts((a-b)>>31?"<":a^b?">":"=");}
prints '>' if a > b, '<' if a < b, '=' if a == b
int overflow is UB. Just don't overflow.
// declare a and b as ints
a,b;

// defaults to int
main()
{
  scanf("%d%d",&a,&b);
   /*
    * (a-b)>>31 signbit of a-b
    * a^b a xor b -> 0 if they are equal
    */
  puts(((a-b)>>31) ? "<" : (a^b) ? ">" : "=");
}

88 89 bytes
main(a,b){scanf("%d%d",&a,&b);a+=1<<31;b+=1<<31;for(;a&&b;a--)b--;putchar(a?b?48:49:50);}

This starts by adding 1<<31 (INT_MIN) to a and b, so that 0 now corresponds INT_MIN. Then loops and decrements a and b every loop until either is 0, then prints 0, 1 or 2
 depending on whether a, b or both are 0.
120 119 bytes
main(a,b,c){scanf("%d%d",&a,&b);c=1<<31;a^=c;b^=c;for(c~=c;!c;c/=2)if(a&c^b&c){putchar(a?48:49);return;}putchar(50);}

It's not the shortest solution as it is but might be golfed down a bit by better golfer than me. (Or just people with more knowledge of C than me)
The idea is to mask each bit, starting from the left one and checking for inequality. The rest should explain itself. Since negative numbers start with a 1 bit, I first invert the first bit with a^=1<<31.

I can't test my solutions for the moment, so feel free to point out mistakes.

The first solution has a couple of problems: 1. The happy ;) smiley  should be a sad ); smiley. 2. a&b only tests if a and b have bits in common; you need &&.

@Dennis, you're right, thanks.

71 bytes
main(x,y,z){scanf("%d%d",&x,&y);putchar((z=x-y)?(z&(z>>31))?50:49:51);}

http://ideone.com/uvXm6c

Your ideone has parentheses around z=x-y and I'm pretty sure they are necessary. You can also save two characters by using 49, 50and51directly, instead of adding48`.

Assignment has a lower precedence than the ternary operator: http://en.cppreference.com/w/c/language/operator_precedence

Your code above is missing a semicolon, and it fails for -2000000000 2000000000, as well as any other combination of integers that cause overflow in the subtraction.

68 characters
int main(a,b){scanf("%d%d",&a,&b);putchar(a-b?((unsigned)a-b)>>31:2);}

Puts ASCII character 1, 2 or 3 for less than, greater than or equal, respectively.

This won't work if a-b overflows.

I think I'm not even going to try at writing short code. What I will attempt is to perform this comparison in a way that is portable per the C99 spec.
int a, b;   // Let's assume these are initialized
int sign_a = a ? ((a|7)^2)%2 + ((a|7)^3)%2 : 0;

The modulo operator preserves sign, but it may well produce a zero (including negative zero), so we ensure we have both an odd and even value for it to check (even without knowing if we are using ones complement). Arithmetic operations may overflow, but bitwise will not, and by ensuring there are bits both set and cleared we avoid inadvertently converting our number into negative zero or a trap value. The fact that two operations are required to do so oddly should not matter, because the possible trap representation doesn't cause undefined behaviour until put in an lvalue. Doing the operation with bit 0 toggled ensures we get exactly one non-zero remainder. Armed with the knowledge of both signs, we can decide how to proceed with the comparison.
char result="\0<<>=<>>\0"[4+3*sign_a+sign_b]
if (!result) {   // signs matching means subtraction won't overflow
  int diff=a-b;
  int sign_diff=diff ? (diff|7^2)%2 + (diff|7^3)%2 : 0;
  result = ">=<"[1-sign_diff];
}

This method may be one of a few that permit extracting the sign of an integer negative zero. We solve that by explicitly checking for zero. If we were golfing for real, we could of course allow the comparison of two zeros to also perform the subtraction.

C 80 chars
a,b,c=1<<31;main(){scanf("%d%d",&a,&b);putchar(a^b?(a&c^b&c?a:a-b)&c?60:62:61);}

It prints '<', '>' or '=', as it should.
C 63 chars
A new approach:
a;main(b){scanf("%d%d",&a,&b);putchar(50+(0L+a-b>>42)+!(a-b));}

Prints '1', '2' or '3'.


text:
Write a Polyquine
A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins.
1 I made that up. Or rather, Geobits did. Apparently, he wasn't the first one either, though.
Rules for Quines
Only true quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, without:

reading your source code, directly or indirectly.
relying on a REPL environment which just simply evaluates and prints every expression you feed it.
relying on language features which just print out the source in certain cases.
using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)

Furthermore, your code must contain a string literal.
Rules for Polyglots
The two languages used must be distinctly different. In particular:

They must not be different versions of the same language (e.g. Python 2 vs. Python 3).
They must not be different dialects of the same language (e.g. Pascal vs. Delphi).
One language may not be a subset of the other one (e.g. C vs. C++).

"your code must contain a string literal" Even in languages that have no string literals, such as Brainfuck?

@PeterOlson The purpose of the rule is avoid a few loopholes in the golfing-specific languages (e.g. this one). As I can't anticipate what removing or weakening the rule would lead to (and as I'm not a fan of changing rules unless absolutely necessary), I'm sorry, but BF submissions won't be valid for the purpose of this challenge. If it's any consolation, a BF submission would likely not be competitive anyway. ;)

"he wasn't the first one either" links to where?

C is not really a subset of C++.

Do two different Brainf**k-based languages count as the same language, such as Brainf**k and MOO?

Would requiring the code print out its source followed by its own byte count be sufficiently anti-loophole?

CJam/GolfScript, 34 bytes
{"__X.0#@@?LL
;~"N}__X.0#@@?LL
;~

The byte count contains a trailing linefeed, since the program wouldn't be a quine without it.
While CJam and GolfScript are very similar in some aspects, there are a lot of differences. To make this an "honest" polyquine, I decided to rely on the differences as much as possible. Except for the block and string syntax (which the languages share with oh so many others), no part of the code achieves exactly the same in both languages.
The online GolfScript interpreter has a bug; this program works only with the official interpreter.
Example run
$ cat polyquine
{"__X.0#@@?LL
;~"N}__X.0#@@?LL
;~
$ md5sum polyquine <(cjam polyquine) <(golfscript polyquine)
e2f1f3cd68abbbceec58080513f98d9a  polyquine
e2f1f3cd68abbbceec58080513f98d9a  /dev/fd/63
e2f1f3cd68abbbceec58080513f98d9a  /dev/fd/62

How it works (CJam)
" Push that block.                                                                        ";

{"__X.0#@@?LL
;~"N}

" Push two copies of the block, 1 (computed as 1**0) and rotate the block copies on top.  ";

__X.0#@@

" If 1 is truthy (oh, the uncertainty), execute the first copy; else, execute the second.
  Evaluating the block pushes the string it contains; N pushes a linefeed.                ";

?

" Push two empty arrays.                                                                  ";

LL

" Discard one empty array and dump the second.                                            ";

;~

" (implicit) Print all items on the stack.                                                ";

How it works (GolfScript)
# Push that block.

{"__X.0#@@?LL
;~"N}

# Push a copy of the block; _ and X are noops, # initiates an inline comment.

__X.0#@@?LL

# Discard the 0 and execute the copy of the block.
# Evaluating the block pushes the string it contains; N is a noop.

;~

# (implicit) Print all items on the stack, followed by a linefeed.

CJam/GolfScript, 12 bytes
{"0$~"N}0$~

Cheaty solution that avoids the languages' differences as much as possible.
Try it online:

CJam
GolfScript

How it works (CJam)
 "0$~"       " Push that string.                                                          ";
      N      " Push a linefeed.                                                           ";
{      }0$~  " Push a copy of the block and execute it.                                   ";
             " (implicit) Print the stack.                                                ";

How it works (GolfScript)
 "0$~"       # Push that string.
      N      # Undefined token (noop).
{      }0$~  # Push a copy of the block and execute it.
             # (implicit) Print the stack, followed by a linefeed.

C#/Java, 746 bytes
I use the property that chars in Java can be written as identical unicode sequences. If we have A instruction for C# compiler and B instruction for Java, we can use the following code fragment:
//\u000A\u002F\u002A
A//\u002A\u002FB

It will be "recognized" by the following way with C#:
//\u000A\u002F\u002A
A//\u002A\u002FB

And by the following way by Java:
//
/*
A//*/B

Because of \u000A is line break, \u002F is / and \u002A is * in Java.
So the final polyglot-quine is:
//\u000A\u002F\u002A
using System;//\u002A\u002F
class Program{public static void//\u000A\u002F\u002A
Main//\u002A\u002Fmain
(String[]z){String s="//@#'^using System;//'#^class Program{public static void//@#'^Main//'#main^(String[]z){String s=!$!,t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{!&!!,!&n!,!&&!,!&@!,!&#!,!&'!,s};for(int i=0;i<7;i++)t=t.//@#'^Replace//'#replace^(!!+(char)a[i],b[i]);//@#'^Console.Write//'#System.out.printf^(t);}}",t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{"\"","\n","\\","\\u000A","\\u002F","\\u002A",s};for(int i=0;i<7;i++)t=t.//\u000A\u002F\u002A
Replace//\u002A\u002Freplace
(""+(char)a[i],b[i]);//\u000A\u002F\u002A
Console.Write//\u002A\u002FSystem.out.printf
(t);}}

However, the size is too huge because of languages verbosity.
Compilation available on ideone.com: C#, Java.

Welcome to the Programming Puzzles & Code Golf community!

I know it's been almost two years, but you can golf 58 bytes. Try it online Java. and Try it online C# .NET.

Did you mean 688 bytes?

Python 3 and JavaScript, 134 bytes
Here's my (final?) attempt:
a='eval(a.split(" ")[2%-4]),1//2# q=String.fromCharCode(39);console.log("a="+q+a+q+a.slice(-8)) print(a[-12:]%a) a=%r;eval(a)';eval(a)

It can probably be golfed a bit more, especially if anyone knows a better way to get single quotes in JavaScript.

Boiled down, the program looks like this:
a='a long string';eval(a)

The eval() function will evaluate expressions in both languages. So the long string gets executed:
eval(a.split(" ")[2%-4]),1//2# ... the rest gets commented out

This splits the long string by spaces and evaluates the substring indexed by 2%-4. JavaScript will run the third substring (2 % -4 == 2) and Python the second last (2 % -4 == -2), because their modulo operators behave differently for negatives.
The rest of the string gets ignored in both languages. JavaScript stops at the //, while Python sees it as integer division and stops at the #.
So JavaScript prints the source code to the console here:
q=String.fromCharCode(39);console.log("a="+q+a+q+a.slice(-8))

And Python here:
print(a[-12:]%a)

Both make use of the final part of the string, which is a template of the program:
a=%r;eval(a)

+1 Golfed it to 140 bytes: a='print(a[78:]%a)1q=String.fromCharCode(39);console.log("a="+q+a+q+a.slice(82))1a=%r;eval(a.split(1)[0|0=="0"])';eval(a.split(1)[0|0=="0"]). Tested in JavaScript but not in python... but it should work.

@soktinpk Thanks, but I don't think Python will allow a.split(1).

-8 bytes: q=unescape("%27")

Ruby/Perl/PHP, 52
$b='$b=%c%s%c;printf$b,39,$b,39;';printf$b,39,$b,39;

Copied verbatim from Christopher Durr's Perl quine.
This is rules abuse. Ruby and Perl are definitely not the same language, nor is Perl a subset of Ruby (most of the linked Perl quines don't work in Ruby, for example). But Ruby was designed to be able to look a lot like Perl if you want it to, and this happens a lot when golfing.

Could this be made to work (or does it already) in PHP as well? If I'm reading the doc correctly, you can run it on the command line with -R and you don't need the script tags. http://php.net/manual/en/features.commandline.options.php

I wouldn't call it rule abuse. Finding a quine which works on an intersection of two languages is definitely a valid way to approach this question. However, seeing this is not your own work, I'd prefer if you marked it community wiki.

@chilemagic indeed it does!

@MartinBüttner done.

PHP/Perl - 171
#<?PHP$s=1;$t="";
$a='%s<%cPHP$s=1;$t="";%c$a=%c%s%c;$t==$s?$t="#":$s;printf($a,$t,63,10,39,$a,39,10,63);%c#%c>';$t==$s?$t="#":$s;printf($a,$t,63,10,39,$a,39,10,63);
#?>

Run with:
$ php quine.pl
$ perl quine.pl

The php code is actually running (not just printing itself).

Bash/GolfScript, 73
.~0 ()
{
    declare "-f" @* ".~0" " ()
"+@n.;
    echo '.~0;'
}
.~0;

There is a trailing space on each of the first 3 lines.
Bash/GolfScript, 78
alias :a~a.='eval "alias :a~a."\
;set [61 39]+a[39]+n"":a;echo ":a~a."'
:a~a.

Bash/Ruby, 104 82
"tee`#";puts <<a*2+'a'#`" -<<'a';echo a
"tee`#";puts <<a*2+'a'#`" -<<'a';echo a
a

Older version:
"alias" "puts=f()(tee -;echo a);f"
puts <<a *2+"a"
"alias" "puts=f()(tee -;echo a);f"
puts <<a *2+"a"
a

Bash/Ruby, 128 without undefined behavior
"alias" 'puts=f()(a=`cat`;echo "$a
$a
a");f'
puts <<'a' *2+"a"
"alias" 'puts=f()(a=`cat`;echo "$a
$a
a");f'
puts <<'a' *2+"a"
a

wow, I don't even understand how the Ruby code works :D

@MartinBüttner <<a in Ruby works just like Bash, but returns a string. I didn't write a Ruby program before. I just found a random language with this feature.

I don't know how it works in bash either :P

@MartinBüttner It is called heredoc. <<word returns a string closed by a line with a single word.

Perl 5/Ruby/JavaScript (Node.js)/Bash/Python 2/PHP, 1031 bytes
s=1//2;_=r'''<?#/.__id__;s=+0;#';read -d '' q<<'';s=\';Q='echo s=1//2\;_=r$s$s$s\<\?\#/.__id__\;s=+0\;#$s\;read -d $s$s q\<\<$s$s\;s=\\$s\;Q=$s$Q$s\;eval\ \$Q;echo $q';eval $Q
$_='eval("0"?0?"def strtr(s,f,t);s.tr(f,t) end;class String;def chr(n);self+n.chr end;end":"$u=strtr=(s,f,t)=>[...f].reduce((s,a,i)=>s.replace(RegExp(a,`g`),t[i]),s);printf=console.log;(S=String).prototype.chr=function(n){return this+S.fromCharCode(n)}":[]&&"sub strtr{eval q(q(X)=~y/X/X/r)=~s/X/shift/ger}");printf(strtr("%s<?#/.__id__;s=+0;#j;read -d jj q<<jj;s=zj;Q=jecho s=1//2z;_=rksksksz<z?z#/.__id__z;s=+0z;#ksz;read -d ksks qz<z<ksksz;s=zzksz;Q=kskQksz;evalz zkQ;echo kqj;eval kQwk_=j%sj;eval(k_);//;#jjj;f=jjjs=1//2;_=r%%s%%s%%s;f=%%s%%s%%s;q=_[18]*3;print f%%%%(q,_,q,q,f,q)jjj;q=_[18]*3;print f%%(q,_,q,q,f,q)%s","jkwz","".chr(39).chr(36).chr(10).chr(92).chr(92)),[]&&"s=1//2;_=r".chr(39).chr(39).chr(39),$_,$u?"":"".chr(10));';eval($_);//;#''';f='''s=1//2;_=r%s%s%s;f=%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)''';q=_[18]*3;print f%(q,_,q,q,f,q)

Verify it online!
Based on my updates to this answer, I thought I'd try and optimise out the code that prints a different permutation, but ended up adding in Bash, which added a load more bytes anyway. Whilst this is more optimised than my first attempt (saved over 300 bytes) I'm sure it can still be golfed further.

Alternative Perl 5/Ruby/JavaScript (Node.js)/Bash/Python 2/PHP, 1040 bytes
s=1//2;_=r'''<?#/.__id__;s=+0;#';read -d '' q<<'';s=\';Q='echo s=1//2\;_=r$s$s$s\<\?\#/.__id__\;s=+0\;#$s\;read -d $s$s q\<\<$s$s\;s=\\$s\;Q=$s$Q$s\;eval\ \$Q;echo $q';eval $Q
$_='$z=0?"$&".next+92 .chr+10 .chr: 0..a||eval("printf=console.log;unescape`$%27%5C%0Ak`");$q=$z[1]?$z[1]:h^O;printf("%s%s%s%s<?#/.__id__;s=+0;#%s;read -d %s%s q<<%s%s;s=%s%s;Q=%secho s=1//2%s;_=r%ss%ss%ss%s<%s?%s#/.__id__%s;s=+0%s;#%ss%s;read -d %ss%ss q%s<%s<%ss%ss%s;s=%s%s%ss%s;Q=%ss%sQ%ss%s;eval%s %s%sQ;echo %sq%s;eval %sQ%s%s_=%s%s%s;eval(%s_);//;#%s%s%s;f=%s%s%ss=1//2;_=r%%s%%s%%s;f=%%s%%s%%s;q=_[18]*3;print f%%%%(q,_,q,q,f,q)%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)%s",[]&&"s=1//2;_=r",$r=[]&&$q,$r,$r,$q,$q,$q,$q,$q,$b=$z[2]?$z[2]:chr(92),$q,$q,$b,$d=$z[0]?$z[0]:h^L,$d,$d,$b,$b,$b,$b,$b,$d,$b,$d,$d,$b,$b,$d,$d,$b,$b,$b,$d,$b,$d,$d,$d,$b,$b,$b,$d,$d,$q,$d,$n=$z[3]?$z[3]:chr(10),$d,$q,$_,$q,$d,$q,$q,$q,$q,$q,$q,$q,$q,$q,$z[4]?"":$n);';eval($_);//;#''';f='''s=1//2;_=r%s%s%s;f=%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)''';q=_[18]*3;print f%(q,_,q,q,f,q)

Verify it online!
A little closer to my original approach, but the repetition of the args for printf is still insane. Using positional arguments instead make this only work in Chrome and is tricky to get working in PHP as well because the $s in %1$s is interpolated, but could save a lot of bytes, perhaps using a combination of the two approaches...

Ruby/Mathematica, 225 bytes
Here is my own very beatable polyquine (which serves as example and proof-of-concept):
s="s=%p;puts s%%s;#Print[StringReplace[s,{(f=FromCharacterCode)@{37,112}->ToString@InputForm@s,f@{37,37}->f@37}]]&@1";puts s%s;#Print[StringReplace[s,{(f=FromCharacterCode)@{37,112}->ToString@InputForm@s,f@{37,37}->f@37}]]&@1

The first part is based on this Ruby quine and is basically:
s="s=%p;puts s%%s;#MathematicaCode";puts s%s;#MathematicaCode

The string assignment is exactly the same in Mathematica. The puts s%s is interpreted as a product of 4 symbols: puts, the string s, % (the last REPL result or Out[0] if it's the first expression you evaluate) and another s. That's of course completely meaningless, but Mathematica doesn't care and ; suppresses any output, so this is just processed silently. Then # makes the rest of the line a comment for Ruby while Mathematica continues.
As for the Mathematica code, the largest part of it, is to simulate Ruby's format string processing without using any string literals. FromCharacterCode@{37,112} is %p and FromCharacterCode@{37,112} is %%. The former gets replaced with the string itself, (where InputForm adds the quotes) the latter with a single %. The result is Printed. The final catch is how to deal with that # at the front. This is Mathematica's symbol for the first argument of a pure (anonymous) function. So what we do is we make all of that a pure function by appending & and immediately invoke the function with argument 1. Prepending a 1 to a function call "multiplies" the result with 1, which Mathematica again just swallows regardless of what kind of thing is returned by the function.

reticular/befunge-98, 28 bytes [noncompeting]
<@,+1!',k- ';';Oc'43'q@$;!0"

Try reticular! Try befunge 98!
Anything in between ;s in befunge is ignored, and ! skips into the segment between ;s for reticular. Thus, reticular sees:
<@,+1!',k- ';';Oc'43'q@$;!0"
<                             move left
                           "  capture string
                          0   push zero
                        ;!    skip `;` (end program)
                       $      drop zero
                     q@       reverse TOS
                 '43'         push 34 (")
                c             convert to char
               O              output all
              ;               end program

Befunge sees:
<@,+1!',k- ';';Oc'43'q@$;!0"
<                            move left
                           " capture string
                         !0  push 1
              ;         ;    skip this
         - ';'               push 27
       ,k                    output top 27 chars
   +1!'                      push 34 (")
  ,                          output "
 @                           end program

C/PHP, 266 304 300 282 241 203 + 10 bytes
//<?php
function main($a){printf($a="%c//<?php%cfunction main(%ca){printf(%ca=%c%s%c,13,10,36,36,34,%ca,34,36,10,10,10);}%c#if 0%cmain();%c#endif",13,10,36,36,34,$a,34,36,10,10,10);}
#if 0
main();
#endif

+10 bytes because compiling in C requires the GCC compiler flag -Dfunction=.
How it works (in PHP):

The PHP interpreter simply prints everything before the <?php as HTML. // is not a comment in HTML, so it's simply printed.
main is declared as a function with a variable a.
printf prints a carriage return (to override the already-printed //) and then the source code, using a standard C/PHP quining method.
#if 0 is ignored by PHP.
main($a) initializes an empty variable a. (Previously used error_reporting(0) to ignore errors caused by calling main())
#endif is also ignored by PHP.

How it works (in C):

//<?php is a single-line comment, so it is ignored.
The function keyword is ignored due to the command-line compiler argument -Dfunction=.
GCC and Clang don't care if variables start with or contain $. (This saved the day.)
printf prints a carriage return (useless in this instance) and then the source code, using a standard C/PHP quining method.
#if 0 ignores everything until the endif, so PHP can call main.
#endif ends the "ignore me" block.

Wumpus/><>/Befunge-98 31 bytes
"]#34[~#28&o@,k+deg0 #o#!g00

Try it in Wumpus!,
Try it in ><>!,
Try it in Befunge-98!
How it Works:
Wumpus Code:
  " Start string literal
    Bounce off end of line and come back
  " End string literal
    ]      Push top of stack to bottom
     #34   Push double quote
        [~ Get bottom of stack and swap it with the double quote
          #31    Push 31
             &o@ Print the top 31 items on stack and terminate program

><> Code:
  "    Start string literal
       Wrap when it reaches the end of the line
  "    End string literal
    ]# Clear stack and reflect
  "    Wrapping string literal again, but backwards
                        +2: Copy the space and add 2 to get "
                    #o#!    Skip into the printing loop
                            Exit with an error

Befunge-98 Code:
  "   Wrapping string literal
    ] Turn right
    ] Turn right again, going West
  "   Wrapping string literal going West
                    !+2: Get double quote and invert it
                 #o#     Skip over the o instruction
            +2:$         Get double quote
         +ff             Push 30
      @,k                Print 30+1 items from the stack and terminate program.

><> and CJam, 165 bytes
"~~~~~~~~~~~~~~~~~~~~~~~r00gol?!v93*0.Hi
'                               <       .1*5av!?log10oar~~~r
'"`{"`"\"_~e#.21 <.2+4*96;!?log10oa"}_~e#.21 <.2+4*96;!?log10oa

To CJam, the program starts with a multi-line string literal. This is escaped with `, and then it uses the standard quine to print the quine code, as well as a trailing comment.
To ><>, the first " starts a string literal that goes through the entire first row, pushing every character to the stack. After that, the trailing spaces (created due to the input being padded) are deleted, and then the stack is reversed. Every character in the stack (i.e. the entire first row) is output, and then it moves down to the second row.
The second row essentially does the same thing, except that it's in the opposite direction, so you don't need to reverse the stack. (I do anyway, because I have to delete the trailing spaces.)
Finally, it moves on to the third line. The only major difference is that you must skip the CJam block, which is done using . The single quote captures the entire line (again, backwards), and then it is output.

C/Lisp, 555 bytes
t(setq /*;*/){}main(){char q='\"',s='\\';char*a=
"~%t(setq /*;*/){}main(){char q='~A';char*a=
~S;char*b=/*
)(setq a ~S)
(setq */ ~S;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}~%";char*b=/*
)(setq a "\\\"',s='\\\\")
(setq */ "
t(setq /*;*/){}main(){char q='%c%c',s='%c%c';char*a=
%c%s%c;char*b=/*
)(setq a %c%c%c%c%c',s='%c%c%c%c%c)
(setq */ %c%s%c;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}
";printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}

Intentionally blank first line.

Vyxal D, 70 bytes/ Python 3, 77 bytes
a="`q‛:Ė+34Cp‛a=print('a=%r;exec(a[13:])#\\140:Ė'%a)";exec(a[13:])#`:Ė

Vyxal : Try it Online!
a="`q‛:Ė+34Cp‛a=print('a=%r;exec(a[13:])#\\140:Ė'%a)";exec(a[13:])#`:Ė

Python : Try it online!
The difference beetween the number of bytes is due to the fact that vyxal and python doesn't use the same charset
Explanation :

Vyxal

a="                            # do nothing revelent here
   `q‛:Ė+                 `:Ė  # structure for a quine
         34Cp‛a=p              # prepend `a="` to the string
                 rint          # do stuff that somehow push 0 to the stack
                     (         # for loop over 0 (do nothing)
                        #      # comment and implicily close the loop
                               # implicit output

Python

The quine is a variation of a="print('a=%r;exec(a)'%a)";exec(a)

05AB1E/2sable, 14 bytes, non-competing
0"D34çý"D34çý

Try it online! (05AB1E)
Try it online! (2sable)
2sable is derived from 05AB1E and is similar, but has major differences.
Trailing newline.

I don't know what the current state of 2sable and 05AB1E is, but last time I checked I would have considered them to be different dialects of one language.

C/TCL, 337 bytes
#define set char*f=
#define F
#define proc main(){
set F "#define set char*f=
#define F
#define proc main(){
set F %c%s%c;
proc /* {} {}
puts -nonewline %cformat %cF 34 %cF 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}
";
proc /* {} {}
puts -nonewline [format $F 34 $F 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}

C/Vim 4.0, 1636 bytes
Contains control characters.
map () {}/*
map g ;data0df"f"cf"
f"cf"
f"D2kyyP;g6k2dd4x5jA"JxA","JxA","jyyPkJxA"jok;g2kdd4xkJx3jdd
map ;g O"vdldd0i# 0# 1# 2# 3# 4# 5# #0lx2lx2lx2lx2lx2lx2lx:s/##/#/g
o:s//"/gk0y2lj02lp"addk@ao:s//\\/gk0ly2lj02lp"addk@ao:s///gk04ly2lj02lp05l"vp"addk@ao:s///gk05ly2lj02lp05l"vp"vp"addk@ao:s//
/gk06ly2lj02lp05l"vp"vp"vp"addk@ao:s//
/gk02ly2lj02lp05l"vp"addk@a
unmap ()

map ;data o*/ char*g[]={"map () {}/*#2map g ;data0df#0f#0cf#0#5#3f#0cf#0#5#3f#0D2kyyP;g6k2dd4x5jA#0#3JxA#0,#0#3JxA#0,#0#3jyyPkJxA#0#3jo#3k;g2kdd4xkJx3jdd#2map ;g O#4#4#4#4#3#0vdldd0i## 0## 1## 2## 3## 4## 5## ###30lx2lx2lx2lx2lx2lx2lx:s/####/##/g#5o:s//#0/g#3k0y2lj02lp#0addk@ao:s//#1#1/g#3k0ly2lj02lp#0addk@ao:s//#4#4#3/g#3k04ly2lj02lp05l#0vp#0addk@ao:s///g#3k05ly2lj02lp05l#0vp#0vp#0addk@ao:s//#4#4#5/g#3k06ly2lj02lp05l#0vp#0vp#0vp#0addk@ao:s//#4#4#5/g#3k02ly2lj02lp05l#0vp#0addk@a#2unmap ()#2#2map ;data o*/ char*g[]={","#A#0#a#0,#0#b#0,#0#c#0#C#2","}; /*#3#2#2#0*/  print(char*s){char*t=s,c,d;while(c=*t++)if(c==35){c=*t++;if(c==35)putchar(c);else if(c==48)putchar(34);else if(c==49)putchar(92);else if(c==50)printf(#0#1n#0);else if(c==51)putchar(27);else if(c==52)putchar(22);else if(c==53)putchar(13);else if(c>64&&c<91)print(g[c-65]);else printf(g[c-97]);}else putchar(c);}  main(){print(g[1]);}"}; /*

"*/  print(char*s){char*t=s,c,d;while(c=*t++)if(c==35){c=*t++;if(c==35)putchar(c);else if(c==48)putchar(34);else if(c==49)putchar(92);else if(c==50)printf("\n");else if(c==51)putchar(27);else if(c==52)putchar(22);else if(c==53)putchar(13);else if(c>64&&c<91)print(g[c-65]);else printf(g[c-97]);}else putchar(c);}  main(){print(g[1]);}

Your Vim needs to have the following set:
set noai
set wm=0
set nosi
set tw=0
set nogdefault

Perl/Javascript (SpiderMonkey), 106 bytes
$_='$q=+[]?h^O:unescape("%27");print("$_="+$q+$_+$q+";eval($_)"||(q($_),"=$q$_$q;",q(eval($_))))';eval($_)

Try the Perl online!
Try the JavaScript online!
Explanation
The quine data is stored in $_ in both languages and then evaled, which is pretty much standard procedure in Perl. I chose SpiderMonkey on TIO as it has a print function, but this could easily be ported to browser for + 20 bytes (add eval("print=alert"); to the beginning of $_s definition).
Perl sees the data stored in $_ and evals it as usual. Since +[] is truthy in Perl,' is stored in $q via the stringwise-XOR of h and O. The final trick is in the call to print where the first part for JavaScript uses +, which in Perl treats all items as numbers, and adds up to 0, then we use the || operator to return what we actually want (q($_),"=$q$_$q;",q(eval($_))) which is equivalent to "\$_=$q$_$q;eval(\$_)".
In JavaScript, +[] returns 0, so we call unescape("%27") to store ' in $q (unfortunately, atob doesm't exist in SpirderMonkey...). In the call to print, since + is the concatenation operator in JavaScript, the first block builds the desired output and the second part after the || is ignored.
Thanks to Patrick Roberts' comment for the unescape trick!

Perl/JavaScript (Browser), 108 bytes
$_='eval("q=_=>_+``;printf=console.log");printf(q`$_=%s%s%s;eval($_)`,$q=+[]?h^O:atob("Jw"),$_,$q)';eval($_)

Try the Perl online!

$_='eval("q=_=>_+``;printf=console.log");printf(q`$_=%s%s%s;eval($_)`,$q=+[]?h^O:atob("Jw"),$_,$q)';eval($_)

Explanation
We store the quine data in $_ in both languages and then eval it, which is pretty much standard procedure in Perl.
Perl sees the data stored in $_ and evals it as usual. The eval within $_ is executed and fails to parse, but since it's eval, doesn't error. printf is then called, with a single quoted string q(), with ` as the delimter, as just using ` would result in commands being executed in shell, then for the first use of $q, since +[] is truthy in Perl, ' is stored in $q via stringwise-XOR of h and O.
In JavaScript, the eval block within $_ sets up a function q, that returns its argument as a String and aliases console.log to printf, since console.log formats string like printf in Perl. When printf is called +[] returns 0, so we call atob to decode ' and store in $q.

Perl 5/Ruby/PHP/JavaScript (Browser), 153 bytes
$_='$z=0?"$&".next: 0..a||eval("printf=console.log;atob`JCc`");printf("%s_=%s%s%s;eval(%s_);",$d=$z[0]?$z[0]:h^L,$q=$z[1]?$z[1]:h^O,$_,$q,$d);';eval($_);

Try the Perl online!
Try the Ruby online!
Try the PHP online!

$_='$z=0?"$&".next: 0..a||eval("printf=console.log;atob`JCc`");printf("%s_=%s%s%s;eval(%s_);",$d=$z[0]?$z[0]:h^L,$q=$z[1]?$z[1]:h^O,$_,$q,$d);';eval($_);

C/dc, 152 bytes
z1d//[[z1d//]P91PP93P[dx]Pq
;main(){char*a="z1d//[[z1d//]P91PP93P[dx]Pq%c;main(){char*a=%c%s%c;printf(a,10,34,a,34);}//]dx";printf(a,10,34,a,34);}//]dx

Taking advantage of comments, yeah!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Forcing the Horse
This is a simple one: create the shortest browser script to change every appearance of force on a web page into horse. This script needs to be able to be pasted into the console and work on most modern browsers.
You must replace all occurences of the word force and conjugates of the word force (forcing, forced, reinforce). The cases must also be preserved.
You must not change any occurences which are not visible when the page is displayed in a browser. For example, meta tags or comments.
Example
This is a fOrcE log. It makes people who touch it very forceful. Don't try forcing it.

This is a hOrsE log. It makes people who touch it very horseful. Don't try horsing it.

Unfortunately this is a Javascript only challenge. The shortest code wins.

Lol for xkcd XD

forcing doesn't contain the word force.

Either the question allows replacement of forc into hors - or it is the replacement of all the different conjugations of force into their horse versions. In the former case, we get things like "Reinhorsing", etc. In the latter, only forcing would be an exception. OP should clarify.

What about the equine equivalents of forcing, forcibly, forceps...?

"...any occurrences which are not visible when the page is displayed in a browser." is far too general. In particular, there are dozens or even hundreds of different ways to insert non-visible content into web pages. Perhaps you should just limit the exclusion to one or two specific types of tag. This prevents .innerHTML replace-all solutions, which I'm guessing is why you want the exceptions in the first place.

@COTO: Visibility as JavaScript understands it is easily achievable. Of course, that doesn't cover white text on white background, etc.

@Dennis: I'm just saying that there are numerous non-visible tags, several CSS properties that can render elements invisible, numerous attributes whose values are never seen (and numerous other attributes whose values are seen), elements whose visibility is conditional, etc., etc.  If you want to write code detecting the 101 different possibilities, more power to you.

I don't think "reinforce" is a conjugate of "force".

@Ypnypn What would the right word be?

@BetaDecay I added an answer.  Am I too late to play?

Can we use LiveScript?

@nyuszika7h only if you add the size of livescript.js to your byte count.  :)

175 bytes, ES5, XPATH
This tests successfully in the latest Firefox and Chrome.  Criticism is welcome!  This is my first golf swing, and I hope I'm doing it right.
d=document,f=d.evaluate('//text()',d,{},7,{});for(i=0;t=f.snapshotItem(i++);)t.data=t.data.replace(/(f)(or)(c)/ig,function(a,b,c,e){return(b=='f'?'h':'H')+c+(e=='c'?'s':'S')})

The document.evaluate() method is supported by all major browsers except IE, which I hope satisfies the requirement for "most modern browsers".  And because the XPath selector selects only text nodes, this ought to leave attributes, comments, namespaces, and other data not intended for display untouched without needing to check for each node's offsetParent.
Ungolfed version:
var force = document.evaluate('//text()', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

for (var i = 0; textNode = force.snapshotItem(i++); /* nothing */) {
    textNode.data = textNode.data.replace(
        /(f)(or)(c)/ig,
        function (full, $1, $2, $3) {
            return ($1 == 'f' ? 'h' : 'H' )
                + $2
                + ($3 == 'c' ? 's' : 'S' );
        }
    );
}

Or if I replace function / return with ECMA6 fat arrow notation, I can get it down to 163 characters.
d=document,f=d.evaluate('//text()',d,{},7,{});for(i=0;t=f.snapshotItem(i++);)t.data=t.data.replace(/(f)(or)(c)/ig,r=(a,b,c,e)=>(b=='f'?'h':'H')+c+(e=='c'?'s':'S'))

This syntax currently only works in Firefox though, I think.  Until more browsers adopt this syntax, the 175-byte solution above shall remain my official entry for the game.

Very interesting approach! There are two differences between our answers (which answer is behaving correctly is for the OP to judge): 1. Your regex will turn FORC into HORS. 2. Your code modifies all text nodes, while checking offsetParent filters out all tags with display:none style (which are not displayed in the browser).

@Dennis Thanks!  Yeah, I can add (?=e|ing) to my regexp if OP deems it necessary.  Regarding display: none, I interpreted "For example, meta tags or comments." to mean stuff that isn't text nodes should be left alone, while text nodes, including invisible nodes, should be changed.  I would be interested to see the OP confirm his intentions though.

@rojo Yep, you interpreted it correctly

ECMAScript 5, 248 233 193 191 182 bytes
for(w=(d=document).createTreeWalker(d,4);t=w.nextNode();)
if(t.parentNode.offsetParent)t.data=t.data.replace(/(f)(or)(c)/gi,
function(a,b,c,d){return(b<'f'?'H':'h')+c+(d<'c'?'S':'s')})

Tested in Chrome and Firefox.
Ungolfed version
We should only modify visible TextNodes; URLs, attributes, etc. are not displayed in the browser. We can use a TreeWalker to find all of them. Visible TextNodes will be identified by checking if their ParentNode has a truthy offsetParent.1
// Create a TreeWalker that walks through all TextNodes.

var walker = document.createTreeWalker(document, NodeFilter.SHOW_TEXT, null, false);

// While there are nodes left,

while(node = walker.nextNode())

// if the node is visible,

    if(node.parentNode.offsetParent)

// search for the string "forc" (ignoring case)

        node.data = node.data.replace(/(f)(or)(c)/gi,

// and replace an uppercase/lowercase F/C with an uppercase/lowercase H/S.

            function(match, F, OR, C)
            {
                return (F != 'f' ? 'H' : 'h') + OR + (C != 'c' ? 'S' : 's')
            }
)

1 This is buggy in IE 9.

You know, you can drop this down to 193 bytes if you get rid of n=[],c=0, populating then looping back through n.  Just do if(t.parentNode.offsetParent)t.data=t.data.replace etc.

200 bytes, ES6
Here is an ES6 version. Run it in latest Firefox's web console.
for(a=document.all,i=0;n=a[i++];)(p=>p&&p.offsetParent?n.innerHTML=n.innerHTML.replace(/f[o0]rc(e|ing)/gi,m=>(v=>{k=[...m];k[0]=k[0]<'F'?'H':'h';k[3]=k[3]<'C'?'S':'s'})()||k.join("")):0)(n.parentNode)

I'll add the ungolfed version if requested :)
Here is the ungolfed version
var all = document.all;
for (var i = 0; i < all.length; i++) {
  if (all[i].parentNode && all[i].parentNode.offsetParent) {
    all[i].innerHTML = all[i].innerHTML.replace(/f[o0]rc(e|ing)/gi, function(matched) {
      var k = matched.split(""); // convert to array
      k[0] = k[0] == "F"? "H" : "h";
      k[3] = k[3] == "C"? "S" : "s";
      return k.join("");
    })
  }
}

I request an ungolfed version=P

Wow... I thought these would be one-liners... Sort of replace('forc','hors') and that's it. Shows how much javascript I know...

This approach doesn't work. innerHTML will change all occurrences inside visible elements, so if there's a comment inside, it will get touched as well. 2. One could argue that ES6 doesn't really work on most modern browsers.

As Dennis says above, this does not meet all of the requirements, therefore I have unaccepted this answer.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/