text:
Shortest code to make a Too-low --- Too-high game
You have to make a game Too-low --- Too-high (TLTH) in shortest code (in bytes)
Game rules:

Computer will choose a random number out of integer range (-32768..32767).
Now you will think of a number and input it.
The computer will tell if your number is lower (TOO LOW) or higher (TOO HIGH) than the chosen number.
When you guess the number, the computer should display Congrats! You found the number!.

Code Rules:

Do not use the characters T, O, L, W, H, I and G (neither lowercase nor uppercase) in string or character literals.
For instance:
tolower(T);  // Acceptable
cout<<"T";   // Unacceptable
char ch='T'; // Unacceptable

Remove 300 bytes if your code can display the game rules before starting the game.
Remove 50 bytes if your code can count number of turns and display number of turns taken in the end of game like this:
"Congrats! You found the number in n turns!"

where n is number of turns taken, instead of
"Congrats! You found the number!"

Remove 25 bytes from your score if your code can tell user that the number you input is out of integer range.
For example:
Enter the number: 40000
Sorry! This number is out of range
Please Enter the number again:

Remove 25 bytes If your code takes the random number not from any built-in random function.
Remove 10 bytes If your code display "congrats" in color (pick any color except default white).

Submission Rules:

Add a heading with your language name and score with all bounty calculation and its explanation.
Post your golfed and ungolfed code.

Winner

The answer with least bytes wins.
If there is a tie, the answer with the more votes wins.
The winner will be chosen after 5 days.

EDIT:Please show your code's output.
EDIT-2: You can ignore Rule-1 for Rules-2,3 & 4 in Code Rules
Best Of Luck :]

Is the use of o and t in cout<< considered a function call?

@hosch250 No, but cout is a variable of class iostream(I think) but I feel that I should edit my post

"if your code can display the game rules before starting the game" - what is an acceptable form of the game rules?

@JanDvorak please explain(not soo good at english :(  )

In code golf, you need to either 1) make certain string literals free (or all of them, but disallow eval) or 2) specify exactly what output is allowed.

is this a valid explanation of the game rules? WhileURong(USayNumbr;ISayBigrOrSmalr)

@JanDvorak Yes, it is valid

similarly for rules #3 and #4: you need to specify exactly what the output should be

@JanDvorak It is done!

Is this a [tag:code-golf] or a [tag:popularity-contest]? They are mutually exclusive and can't be used together.

Based on your description of the scoring, you have neither a code golf nor a popularity contest. It is a code challenge (with a popularity tiebreaker). Check out the tag wikis. I proposed an edit to tag the challenge appropriately. ps - Jinx! @mniip

@JonathanVanMatre to me the wording sounds like [tag:code-golf], despite the tie-breaker.

Also, I don't particularly like the rule against assisting other players in improving their answer. In the immortal words of Andre the Giant in The Princess Bride, "That's not very sportsmanlike".

If a valid answer has 3 bytes and -2 votes and another one with 650 bytes has 25 votes, who wins? The winning criteria is ambiguous.

I guess it depends on how strictly you interpret "a mixture of source length and some other criterion". That's what I see here, but it turns on whether "Subtract bytes for extra feature X" is an "other criterion" or not.

@JonathanVanMatre So, let it be a code golf and you may help them with small improvements but I have kept something in rules to increase the answer's score you may not tell that

@ victor obviously according to my previous rules the answer with 3 bytes will win

@MukulKumar There is some problem if my output is CONGRATS! YOU FOUND THE NUMBER IN x TURNS!, all caps?

@Victor No, no problem

@Victor Perhaps we can remove 2 bytes per upvote? That would be an interesting metric!

This is impossible, as "Congrats! You found the number!" contains o, t and g.

This question is so . . . David H. Ahl

Can you have "Great! You found the number in x turns!"?

@Oberon Not impossible if you know how to encode octal in strings, see my answer below...

@WallyWest, not needed anymore. See EDIT2.

"Remove 25 bytes If your code takes the random number not from any built-in random function"  These are free points.  http://xkcd.com/221/

And putting EDIT2 kinda makes this more of a code challenge now... a very bland one... What's the point of putting a code restriction if you can't uphold it?

@JonathanVanMatre I completely agree; The "commenting rule" is completely inappropriate for this site.

@MukulKumar: Rule 2 seems incredibly silly given Rule 1 doesn't apply to it. Anyone can significantly reduce their score by just having a simple print statement.

JavaScript (-210 points (190 bytes - 300 (for the rules) - 50 (for the number of guesses) - 25 (for not using any built-in random number source) - 25 (for telling you if the input is out of the range of a signed 16-bit integer)):
Golfed:
alert('Guess number',n=(m=2<<15)/2-new Date%m);for(z=0;a=+prompt(++z);)alert(a>m|a<1-m?m+'-'+-~-m:a==n?'Great! You found the number in '+z+' turns':atob('VE9P\x47E'+(a>n?'hJR0g=':'xPVw==')))

Full code (nicely formatted):
var max = 2 << 15;
var random = max/2 - new Date%max;
var counter = 0;

while (1) {
    var guess = +prompt();

    ++counter;

    if (guess > max | guess < -~-max) {
        alert(-~-max + '-' + max); // Shows that the range is between -32767 and 32768
    } else if (guess > random) {
        alert('TOO HIGH');
    } else if (guess < random) {
        alert('TOO LOW');
    } else if (guess == random) {
        alert('Congrats! You found the number in ' + counter + ' turns');
        break;
    }
}

Output:
ALERT:  Guess number
PROMPT: 5
ALERT:  TOO LOW
PROMPT: 20000
ALERT:  TOO LOW
PROMPT: 30000
ALERT:  TOO HIGH
PROMPT: 25000
ALERT:  TOO HIGH
PROMPT: 22500
ALERT:  TOO HIGH
PROMPT: 21000
ALERT:  TOO HIGH
PROMPT: 20500
ALERT:  TOO HIGH
PROMPT: 20200
ALERT:  TOO LOW
PROMPT: 20400
ALERT:  TOO LOW
PROMPT: 20450
ALERT:  TOO LOW
PROMPT: 20475
ALERT:  TOO HIGH
PROMPT: 20460
ALERT:  TOO LOW
PROMPT: 20468
ALERT:  TOO HIGH
PROMPT: 20464
ALERT:  TOO LOW
PROMPT: 20466
ALERT:  TOO LOW
PROMPT: 34000
ALERT:  -32767-32768
PROMPT: 20467
ALERT:  Great! You found the number in 17 turns!
PROMPT: (nothing)

@IlmariKaronen Sorry, I made a mistake. I've updated my answer.

Thanks, now it runs... but it seems to break if I guess 0. :-( Also, shouldn't there be a space in TOO LOW / TOO HIGH?

Perl 5.10+: 159 144 bytes − 350 = −206 points
say"Guess 16 bit signed number";$==32767-rand 65536;say(TOO.$",$_<0?LOW:HIGH)while++$i,$_=<>-$=;say"Congrats! You found the number in $i turns!"

Edit 2: With the recent rules change that allows me to use any string literal for the "congrats" message, I can save 15 bytes from my original 159-byte solution.  There's nothing particularly novel or interesting about the new code above as compared to the old code (I just got rid of the p function, and call say directly instead), so the remainder of this post will describe the original code, shown below:
sub p{say join$",@_}p Guess,16,bit,signed,number;$==32767-rand 65536;p(TOO,$_<0?LOW:HIGH)while++$i,$_=<>-$=;p Congrats."!",You,found,the,number,in,$i,turns."!"

Yeah, I'm abusing the hell out of rule 1.  Who needs strings, when you can have barewords? ;-)
Run with perl -M5.010 to enable the Perl 5.10+ say feature (or replace the body of the p function with print join$",@_,$/ for an extra cost of 5 bytes).
Bonus scores:

−300 points: "display the game rules before starting the game"
−50 points: "display number of turns taken in the end of game"

The code contains no string literals in a strict sense, so I'd say that rule 1 is, technically, not violated.  The trick is that, in Perl, without use strict, any identifier that doesn't correspond to a known language keyword or subroutine will simple evaluate to its own name.  The function p then simply takes a list of words and prints them out, separated by spaces.
Example play-through:
Guess 16 bit signed number
0
TOO HIGH
-10000
TOO LOW
-5000
TOO HIGH
-7500
TOO LOW
-6250
TOO HIGH
-6875
TOO LOW
-6553
TOO HIGH
-6700
TOO HIGH
-6790
TOO LOW
-6745
TOO HIGH
-6767
TOO LOW
-6756
TOO HIGH
-6761
Congrats! You found the number in 13 turns!

Edit: Oh, right, the rules say I need to post an un-golfed version of the code too, so here it goes.  Technically, it's "de-golfed", since I usually compose my code golf programs in more or less fully golfed form from the beginning, and it can sometimes be tricky to remove all the "golfy" optimizations without fundamentally changing how some parts of the program work.  Still, I've at least tried to add whitespace, comments and more meaningful function / variable names:
sub output {
    # print all arguments separated by spaces, plus a newline:
    # (in the golfed code, I use the special variable $" instead of " " for a space)
    say join " ", @_;
}

# print the rules:
output Guess, 16, bit, signed, number;

# choose a random number between -32768 and 32767 inclusive:
# (in the golfed version, using the special variable $= allows
# the int() to be left out, since $= can only take integer values)
$number = int( 32767 - rand 65536 );

# loop until the input equals the chosen number, printing "TOO LOW / HIGH":
# (the loop ends when $diff == 0, since 0 is false in Perl)
output (TOO, $diff < 0 ? LOW : HIGH) while ++$count, $diff = (<> - $number);

# print congratulations, including the loop count:
output Congrats."!", You, found, the, number, in, $count, turns."!";

Ps. As an alternative, if just using barewords instead of strings feels too cheaty for you, here's a 182-byte solution that doesn't use the letters TOLWHIG even in barewords (but does use them in a transliteration operator).  It still gets the same bonuses, for a total score of 182 − 350 = −168 points:
sub t{pop=~y/kpqvxyz/tolwhig/r}say"Guess 16 bit signed number";$==32767-rand 65536;say uc t"kpp ".($_<0?qpv:xyzx)while++$n,$_=<>-$=;say t"Cpnzraks! Ypu fpund kxe number yn $n kurns!"

The output looks exactly the same as above.  Per the (original) rules, I do use the letters t and i in printing the rules, since it's allowed; eliminating even those uses would only cost two extra bytes, though.  Conversely, making all the output uppercase (which, based on comments above, seems to be allowed) would let me save three bytes.

That is a nice and clever answer! +1 from me

Now that I see this I wonder if it could be beat with Ruby 1.8 if you take the penalty for def method_missing *args;args.join' ';end.

I beat you with good old JavaScript!

Python 2: -80 points (270-300-50)
print"WhileURong(USayNumbr;ISayBigrOrSmalr)"
import random
r=random.randint(-32768,32767)
g=i=1
while g:g=cmp(input(),r);print("C\x6fn\x67ra\x74s! Y\x6fu f\x6fund \x74\x68e number \x69n %d \x74urns!"%i,"\x54\x4f\x4f \x48\x49\x47\x48","\x54\x4f\x4f \x4c\x4f\x57")[g];i+=1

Score is 270 characters, minus 300 for showing the instructions, minus 50 for showing the number of guesses in the "congrats!" string, for a total of negative 80 points.
Ungolfed version of the loop, with unescaped strings:
while g:
    g=cmp(input(),r)
    print ("Congrats! You found the number in %d turns!"%i,
           "TOO HIGH",
           "TOO LOW")[g]
    i+=1

The built-in cmp function returns 0 if the values are equal, -1 if the first is smaller and 1 if the first is bigger. I use the value to index a tuple of strings, and then again as the exit condition of the loop. Indexing a sequence with a negative index (like -1) counts from the end of the sequence, rather than from the start.
I was sorely tempted to skip the imports and just use 4 as my random number, as per XKCD 221 (would that qualify for the -25 character bonus?).
Example run (complete with an error, where I can't do negative math):
WhileURong(USayNumbr;ISayBigrOrSmalr)
0
TOO HIGH
-16000
TOO LOW
-8000
TOO HIGH
-12000
TOO HIGH
-14000
TOO LOW
-13000
TOO HIGH
-13500
TOO HIGH
-13750
TOO LOW
-13625
TOO HIGH
-13712
TOO LOW
-13660
TOO HIGH
-13640
TOO HIGH
-13685
TOO HIGH
-13700
TOO LOW
-13695
TOO LOW
-13690
TOO LOW
-13687
Congrats! You found the number in 17 turns!

Please show your code's sample output.

Isn't this breaking code rule 1? WhileURong(USayNumbr;ISayBigrOrSmalr) contains one or more Os, Ls, Ws, Hs, Is and Gs.

@Cruncher: I'm not sure what you mean, as the program does terminate. After you get the value right g is zero and the while loop ends.

@Blckknght oops, quick read

@Fors You can ignore Rule-1 for Rules-2,3 & 4 in Code Rules

@Fors: The question appears to have been edited a few times since I submitted this answer, but you can see the "edit" at the bottom that exempts later rules from rule 1. That's actually more generous than it used to be!

JavaScript 293, -300 (rules) - 50 (turns display) - 25 (range warning) - 25 (no random function) = -107 (new score)
r=new Date%65536+~(z=32767);n=x="";for((A=alert)("\107uess my number, \111 \147\151ve feedback");(x=prompt())!=r;A(0>(x-~z^x-z)?"\164\157\157 "+(x>r?"\150\151\147\150":"\154\157\167"):"Ran\147e: "+~z+" - "+z))n++;A("C\157n\147ra\164s! Y\157u f\157und \164\150e number \151n "+ ++n+"\164urns!")
I'd claim that by RGB conventions that black is a color, but that would be kinda cheating...
Oh, and might I add, no breaking rule #1, either!
Output in a series of alerts and prompts
ALERT: Guess my number, I give feedback
PROMPT: 0
ALERT: too low
PROMPT: 16000
ALERT: too low
PROMPT: 24000
ALERT: too low
PROMPT: 28000
ALERT: too high
PROMPT: 26000
ALERT: too high
PROMPT: 25000
ALERT: too low
PROMPT: 25500
ALERT: too high
PROMPT: 25250
ALERT: too low
PROMPT: 25375
ALERT: too high
PROMPT: 25310
ALERT: too low
PROMPT: 25342
ALERT: too low
PROMPT: 25358
ALERT: too low
PROMPT: 25366
ALERT: too high
PROMPT: 25362
ALERT: too high
PROMPT: 25360
ALERT: too high
PROMPT: 25359
ALERT: Congrats! You found the number in 16 turns!

Ungolfed code:
r = (new Date)%65536+~(z=32767); //Generates random number in range based off date's milliseconds... I'd use epoch, but I need to conserve
n=x=""; // Sets count and input to blank, these change as time goes on
// The line below sets up a call for `alert`, provides the initial rules, and subsequent loops compares the prompt with the number, as well as sets up "too", "high",  "low" and "out of range" message strings, and provides the feedback
for((A=alert)("\107uess my number, \111 \147\151ve feedback");(x=prompt())!=r;A(0>(x-~z^x-z)?"\164\157\157 "+(x>r?"\150\151\147\150":"\154\157\167"):"Ran\147e: "+~z+" - "+z))
{
    n++; // adds one to count providing the number isn't guessed yet
}
alert("C\157n\147ra\164s! Y\157u f\157und \164\150e number \151n "+ ++n+" \164urns!") // Congratulates the player, and displays the correct number of turns taken

you read the rules carefully ? well you have to post ungolfed code with one output

@MukulKumar sorted...

You can save 4 by prefixing your answer with A=alert; and replacing all of the alert with A. And one more if you move the alert A(0>(x... after the semicolon in prompt())!=r;)n++1.

you can change feedback if too high/low which uses 84 characters currently to i give feedback (which would only require \151 \147\151ve feedback or 24 characters to save 60 characters.

I may be wrong, but I think you can you move the n++ from the for loop into the x=prompt(n++) to save having to do + ++n+ in the final alert. It would save 3.

Javascript, 324 bytes, score -76
[Updated due to rule changes]

324 bytes
-300 for showing the rules
-50 for showing the turns when the user wins
-25 for telling the user when he inputs a number outside the range
-25 for not using built-in random (updated)

Total score: -76
Golfed:
function q(y){return y.replace(/./g,function(x){h=x.charCodeAt(0);return String.fromCharCode(h>32&h<58?h+32:h)})}d=o=32768;alert("WhileURong(USayNumbr;ISayBigrOrSmalr)");for(a=1,n=new Date%(2*o)-o;d-n;a++)d=+prompt(a),alert(d>=o|d<-o?"BAD":d<n?q("4// ,/7"):d>n?q("4// ()'("):"Congrats! You found the number in "+a+" turns!")

Lets ungolf this mess.
First, properly idented (but this is still not very good with obfuscated code):
function q(y) {
  return y.replace(/./g, function(x) {
    h = x.charCodeAt(0);
    return String.fromCharCode(h > 32 & h < 58 ? h + 32 : h)
  })
}

d = o = 32768;
alert("WhileURong(USayNumbr;ISayBigrOrSmalr)");

for (a = 1, n = new Date % (2 * o) - o; d - n; a++)
  d = +prompt(), alert(d >= o | d < -o ? "BAD" : d < n ? q("4// ,/7") : d > n ? q("4// ()'(") : "Congrats! You found the number in " + a + " turns!")

Second, renaming identifiers:
function unencrypt(encrypted) {
  return encrypted.replace(/./g, function(character) {
    charCode = character.charCodeAt(0);
    return String.fromCharCode(charCode > 32 & charCode < 58 ? charCode + 32 : charCode)
  })
}

guess = limit = 32768;
alert("WhileURong(USayNumbr;ISayBigrOrSmalr)");

for (tries = 1, randomNumber = new Date % (2 * o) - o; guess - randomNumber; tries++)
  guess = +prompt(),
  alert(guess >= limit | guess < -limit ? "BAD" : guess < randomNumber ? unencrypt("4// ,/7") : guess > randomNumber ? q("4// ()'(") : "Congrats! You found the number in " + tries + " turns!")

So the unencrypt function gets all characters between ASCII 33 (!) and ASCII 58 (:) and adds 32, converting them in characters in the range A-Z.
Lets ungolf the code more by unecrypting all the strings:
guess = limit = 32768;
alert("WhileURong(USayNumbr;ISayBigrOrSmalr)");

for (tries = 1, randomNumber = new Date % (2 * o) - o; guess - randomNumber; tries++)
  guess = +prompt(),
  alert(guess >= limit | guess < -limit ? "BAD" : guess < randomNumber ? "TOO LOW" : guess > randomNumber ? "TOO HIGH" : "Congrats! You found the number in " + tries + " turns!")

And finally lets move some instructions to other places, replace the long ternary chain with ifs and elses, join concatenating strings, and simplify the math, to increase the readability:
guess = 32768;
alert("WhileURong(USayNumbr;ISayBigrOrSmalr)");

randomNumber = new Date % 65536 - 32768;

for (tries = 1; guess - randomNumber; tries++) {
  guess = +prompt(); // The preceding + is a golfing trick to convert string to number.
  if (guess > 32767 | guess < -32768) {
    alert("BAD");
  } else if (guess < randomNumber) {
    alert("TOO LOW");
  } else if (guess > randomNumber) {
    alert("TOO HIGH");
  } else {
    alert("Congrats! You found the number in " + tries + " turns!");
  }
}

Sample:
ALERT:  WhileURong(USayNumbr;ISayBigrOrSmalr)
PROMPT: 5
ALERT:  TOO LOW
PROMPT: 20000
ALERT:  TOO LOW
PROMPT: 30000
ALERT:  TOO HIGH
PROMPT: 25000
ALERT:  TOO HIGH
PROMPT: 22500
ALERT:  TOO HIGH
PROMPT: 21000
ALERT:  TOO HIGH
PROMPT: 20500
ALERT:  TOO HIGH
PROMPT: 20200
ALERT:  TOO LOW
PROMPT: 20400
ALERT:  TOO LOW
PROMPT: 20450
ALERT:  TOO LOW
PROMPT: 20475
ALERT:  TOO HIGH
PROMPT: 20460
ALERT:  TOO LOW
PROMPT: 20468
ALERT:  TOO HIGH
PROMPT: 20464
ALERT:  TOO LOW
PROMPT: 20466
ALERT:  TOO LOW
PROMPT: 20467
ALERT:  Congrats! You found the number in 16 turns!"

I really like it :)

Please show your code's sample output.

@MukulKumar. Done, output added

C - 272 characters - 300 - 50 - 25 = -103

-300 for displaying the rules;
-50 for telling the player the number of turns;
-25 for not using a standard RNG library.

Golfed code:
main(i){short a,c=i=0,b=time(0);for(a=b;b--;a=(a*233)+4594);b=a;puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");while(1){i++;scanf("%hi",&a);if(a==b){printf("Congrats! You found the number in %i turns!",i);break;}for(c=0;c^9;c++)putchar(c[a<b?"kff7cfn7!":"kff7_`^_!"]-23);}}

Ungolfed:
int main(int i) {
    short a,
          b = time(0),
          c = i = 0;

    for( a = b ; b-- ; a = (a * 233) + 4594);
    b = a;

    puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");

    while(1) {
        i++;
        scanf("%hi", &a);
        if(a == b) {
            printf("Congrats! You found the number in %i turns!", i);
            break;
        }
        for( c = 0 ; c ^ 9 ; c++ )
            putchar(c[ a < b ? "kff7cfn7!" : "kff7_`^_!" ] - 23);
    }
}

Output:

Where is output ?

@IlmariKaronen, EDIT2. Also, I don't just take the epoch.

@Oberon please post the output also

@MukulKumar, posted.

C: 237 - 300 - 50 - 25 - 25 - 10: -173 points
-300 for the rules, -50 for showing the number of guesses, -25 for not using any built-in random number generator, -25 for the out of range message and -10 for colouring the congrats message.
int s[3]={542068564},g,n;main(r){for(r=(short)&r,puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");n++,scanf("%d",&g),s[1]=g<r?5721932:1212631368,g^r;puts(g^(short)g?"OOR":s));printf("\033[31mCongrats! You found the number in %d turns!",n);}

Ungolfed:
int s[3]={542068564},g,n;

main(r){
        for(
                r=(short)&r,
                puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");

                n++,
                scanf("%d",&g),
                s[1]=g<r?5721932:1212631368,
                g^r;

                puts(g^(short)g?"OOR":s)
        );

        printf("\033[31mCongrats! You found the number in %d turns!",n);
}

Example run:
WhileURong(USayNumbr;ISayBigrOrSmalr)
-32769
OOR
32768
OOR
0
TOO HIGH
-16384
TOO HIGH
-24576
TOO HIGH
-28672
TOO LOW
-26624
TOO LOW
-25600
TOO HIGH
-26112
TOO LOW
-25856
TOO LOW
-25728
TOO LOW
-25664
TOO HIGH
-25696
TOO HIGH
-25712
TOO LOW
-25704
Congrats! You found the number in 15 turns!

The last line shows up as red.

Bravo! You Hit all of the bounties !!!

C#: -30 points

345 bytes
-300 for showing the rules
-50 for showing the turns when the user wins
-25 for telling the user when he inputs a number outside the range

Golfed:
int l=-32768,h=32767,n=new Random().Next(l,h),t=0,g=h+1;Console.Write("WhileURong(USayNumbr;ISayBigrOrSmalr)\n");while(n!=g){g=Convert.ToInt32(Console.ReadLine());Console.WriteLine(g==n?"C\x6fn\x67ra\x74s! Y\x6fu f\x6fund \x74\x68\x65 number in {0} \x74urns!":g<l||g>h?"BAD":g<n?"\x54\x4f\x4f \x4c\x4f\x57":"\x54\x4f\x4f \x48\x49\x47\x48",++t);}

To run it, put it in a file (code.cs) and run with scriptcs on the command line: scriptcs code.cs.
Ungolfed: Expanded variable names into something easier to understand, and changed hex letters into real letters.
int low = -32768,
    high = 32767,
    number = new Random().Next(low, high),
    turns = 0,
    guess = h+1;
Console.Write("WhileURong(USayNumbr;ISayBigrOrSmalr)\n");  // instructions
while (number != guess)
{
    guess = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine(
      guess == number                                     // if you got it right
        ? "Congrats! You found the number in {0} turns!"  // give the victory speech
        : guess < low || guess > high                     // if out of range
          ? "BAD"                                         // let them know
          : guess < number                                // if guess is low
            ? "TOO LOW"                                   // tell them low
            : "TOO HIGH"                                  // otherwise tell them high
      , ++turns                                           // preincrement turns, add to output
    );
}

Sample output available here.

Sorry for telling this, but the rule states that "Do not use the characters T, O, L, W, H, I and G (neither lowercase nor uppercase) in string or character literals."

So just replace T, O, L... with \x54, \x4F, \x4C... and you're fine.

Thanks. I just put in hex encodings for the applicable chars in string literals in the golfed version, and modified the scoring accordingly.

Please show your code's sample output.

@MukulKumar see here for output. I also just made a few small changes to the logic, fixed an issue.

bash, -137
Score
273 (bytes) - 300 (rules) - 50 (count tries) - 25 (OOF warning) - 25 (custom PRNG) - 10 (color)
Golfed version
IFS=# a=(`<$0`)
c=65536
y=$[10#`date +%N`%c]
e(){ echo -e ${a[$1]/z/$z};}
e 7
while read x
do((z++,x+=c/2,i=3+(x>y),x==y))&&break
((x<0||x>c-1))&&i=6
e $i
done
e 5
#TOO LOW#TOO HIGH#\e[32mCongrats! You found the number in z turns!#OOR#Guess my number. I'll say HIGH or LOW.

Note that the last line is a comment, so it contains no string or character literals.
Ungolfed version
MYNUMBER=$[10#$(date +%N) % 65536 - 32768]
echo "Guess my number. I'll say HIGH or LOW."

while true; do
    read YOURGUESS
    GUESSES=$((GUESSES + 1))

    if ((YOURGUESS == MYNUMBER)); then
        break
    elif ((YOURGUESS < -32768 || YOURGUESS > 32767)); then
        echo OOR
    elif ((YOURGUESS < MYNUMBER)); then
        echo "TOO LOW"
    else
        echo "TOO HIGH"
    fi
done

echo -e "\e[32mYou found the number in $GUESSES turns!"

Sample output
$ ./tlth
Guess my number. I'll say HIGH or LOW.
-32769
OOR
32768
OOR
0
TOO LOW
16384
TOO HIGH
8192
TOO HIGH
4096
TOO HIGH
2048
TOO HIGH
1024
TOO HIGH
512
TOO HIGH
256
TOO HIGH
128
TOO HIGH
64
TOO HIGH
32
TOO LOW
48
TOO HIGH
40
TOO LOW
44
TOO HIGH
42
Congrats! You found the number in 17 turns!

The last line is printed in green.

C++ 505 + (-300-50-25-25) = 105
-300 : Instructions
-50 : Showing number of turns
-25 : Not using random function
-25 : warning user about input out of range
GOLFED
#include<iostream>
#include<stdlib.h>
using namespace std;int main(){short int a,i=0,*r=new short int;int b=0;a=*r;char t[]={84,79,79,' ','\0'},l[]={76,79,87,'\n','\0'},h[]={72,73,71,72,'\n','\0'};cout<<"WhileURong(USayNumbr;ISayBigrOrSmalr)\n";while(a!=b){cin>>b;if(b<-32768||b>32767){cout<<"Sorry! the number is out of range please enter the number again\n";continue;}i++;if(b<a){cout<<'\n'<<t<<l;}if(b>a){cout<<'\n'<<t<<h;}if(a==b){cout<<"Congrats!You found the number in "<<i<<" turns!";}}return 0;}

UNGOLFED
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    short int a,i=0,*r=new short int;
    int b=0;
    a=*r;
    char t[]={84,79,79,' ','\0'},l[]={76,79,87,'\n','\0'},h[]={72,73,71,72,'\n','\0'};
    cout<<"WhileURong(USayNumbr;ISayBigrOrSmalr)\n";
    while(a!=b)
    {
        cin>>b;
        if(b<-32768||b>32767)
        {
            cout<<"Sorry! the number is out of range please enter the number again\n";
            continue;
        }
        i++;
        if(b<a)
        {
            cout<<'\n'<<t<<l;
        }
        if(b>a)
        {
        cout<<'\n'<<t<<h;
        }
    if( a==b)
    {

            cout<<"Congrats!You found the number in "<<i<<" turns!";
        }
    }
    return 0;
}

OUTPUT

Personally, I could not stop myself.. :)

C, 183-300-25=-142
183 bytes
-300 for the rules
-25 for not using a random library
main(){short g,n=time(0)*(time(0)&1?1:-1);puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");while(g^n)scanf("%d",&g),puts(g>n?"TOO HIGH":g<n?"TOO LOW":"Congrats! You found the number!");}

ungolfed version:
main(){
    short g,n=time(0)*(time(0)&1?:-1);
    puts("WhileURong(USayNumbr;ISayBigrOrSmalr)");
    while(g^n)
        scanf("%d",&g),
        puts(g>n?"TOO HIGH":g<n?"TOO LOW":"Congrats! You found the number!");
}

sample run:
WhileURong(USayNumbr;ISayBigrOrSmalr)
40
TOO HIGH
20
TOO HIGH
1
TOO HIGH
0
TOO HIGH
-20
TOO HIGH
-200
TOO HIGH
-2000
TOO HIGH
-20000
TOO LOW
-10000
TOO LOW
-5000
TOO LOW
-3000
TOO HIGH
-4000
TOO LOW
-3500
TOO HIGH
-3700
TOO HIGH
-3900
TOO HIGH
-3950
TOO HIGH
-3970
TOO LOW
-3960
Congrats! You found the number!

"TOO HIGH" and "TOO LOW" both contain illegal characters TOLWHIGtolwhig.

As does "Congrats! You found the number!" and "WhileURong(USayNumbr;ISayBigrOrSmalr)".

@Fors but those are allowed (see EDIT2).

Indeed they are! By some reason I missed that edit.

@Oberon So is TOO LOW allowed by EDIT 2, too?

@toothbrush "...for Rules 2, 3 & 4 in Code Rules."

J - 190 char -300 -50 = -160 pts
'Congrats, you found the number in ',' turns!',~":1>:@]^:(]`(1[2:1!:2~a.{~71+13 8 8 _39,(5 8 16;1 2 0 1){::~0&>)@.*@-[:".1!:1@1:)^:_~32767-?2^16['WhileURong(USayNumbr;ISayBigrOrSmalr)'1!:2]2

Explanation (recall that J is read from right to left):

'WhileURong(USayNumbr;ISayBigrOrSmalr)'1!:2]2 - Print the rules.
32767-?2^16[ - Toss the return value, and then generate a random number between 0 and 2^16-1 inclusive. Then, adjust it to the range -32768..32767 by subtracting it from 32767.
1>:@]^:(...)^:_~ - The x u^:v^:_ y pattern is kinda like a while loop. x stays constant, and y gets mutated with every execution of u. This continues until either x v y returns 0 or x u y results in no change to y. The ~ swaps the two arguments, so that x will be the random number and y will begin at 1. Our u is >:@], which increments this 1 and returns it, so it acts as a counter and the x u y termination condition can never occur.
[:".1!:1@1: - Take the counter, and ignore its value, using the number 1 instead (1:). Read in a line of input (1!:1) from the keyboard (file handle 1) and execute it (".). This allows J, whose negative sign is normally _, to take numbers in the form -n (evaluates as negation applied to the number n).
]`(...)@.*@- - Take the difference of the random number from before and the guess (-). Now, we select the next action depending on whether this difference is zero (@.*). If it is, return (]`) that 0 as the result for x v y, so that execution terminates, and the whole while loop returns the counter. Else...
71+13 8 8 _39,(5 8 16;1 2 0 1){::~0&> - Return the array 5 8 16 if the number is negative, and 1 2 0 1 if it is positive. Then prepend 13 8 8 _39 and add 71 to everything, so we have either 84 79 79 32 76 79 87 or 84 79 79 32 72 73 71 72.
1[2:1!:2~a.{~ - Turn these numbers to ASCII characters by indexing the alphabet a. with them. Then print them out with 1!:2 (using file handle 2) and return 1 as the result of x v y.
'Congrats, you found the number in ',' turns!',~": - When the loop finishes, it returns the counter. Convert it to a string with ": and put it in between the strings 'Congrats, you found the number in ' and ' turns!'.

Sample output:
   'Congrats, you found the number in ',' turns!',~":1>:@]^:(]`(1[2:1!:2~a.{~71+13 8 8 _39,(5 8 16;1 2 0 1){::~0&>)@.*@-[:".1!:1@1:)^:_~32767-?2^16['WhileURong(USayNumbr;ISayBigrOrSmalr)'1!:2]2
WhileURong(USayNumbr;ISayBigrOrSmalr)
0
TOO HIGH
-20000
TOO LOW
-10000
TOO LOW
-5000
TOO HIGH
-7500
TOO HIGH
-8750
TOO HIGH
-9000
TOO HIGH
-9500
TOO LOW
-9250
TOO HIGH
-9375
TOO HIGH
-9450
TOO LOW
-9400
TOO HIGH
-9425
TOO HIGH
-9437
TOO LOW
-9431
TOO LOW
-9428
TOO HIGH
-9430
TOO LOW
-9429
Congrats, you found the number in 18 turns!

JavaScript -40
335 - 300 (rules) - 50 (count turns) - 25 (out of range)
Not gonna win but a fun way to get the letters I think.
Golfed
!function T(O,L,W,H,I,G){a=T.toString();c=L.floor(65536*L.random())+H;O(W+G+" between "+H+" & "+I);k=(f=a[9]+(d=a[11])+d+" ")+(e=a[17])+a[19]+a[21]+e;l=f+a[13]+d+a[15];for(m=1;(n=prompt(W+G))!=c;m++)n<H||n>I?O("Out of range"):n>c?O(l):O(k);O("Congrats! You found the"+G+" in "+m+" turns!")}(alert,Math,"Guess a",-32768,32767," number")

Ungolfed
!function T(O,L,W,H,I,G){
    fn = T.toString();
    random = L.floor(L.random() * 65536) + H;

    O(W + G + " between " + H + " & " + I);

    tooLow = (too = fn[9] + (o = fn[11]) + o + " ") + (h = fn[17]) + fn[19] + fn[21] + h;
    tooHigh = too + fn[13] + o + fn[15];

    for (n=1; (guess = prompt(W + G)) != random; n++) {
        if (guess < H || guess > I) {
            O("Out of range");
        } else if (guess > random) {
            O(tooHigh);
        } else {
            O(tooLow);
        }
    }

    O("Congrats! You found the" + G + " in " + n + " turns!");
}(alert, Math, "Guess a", -32768, 32767, " number")

Sample output
(ALERT) Guess a number between -32768 & 32767
(PROMPT) Guess a number
9999999
(ALERT) Out of range
(PROMPT) Guess a number
0
(ALERT) TOO LOW
(PROMPT) Guess a number
8008
(ALERT) Congrats! You found the number in 3 turns!

APL (Dyalog) (157 - 300 - 50 = -193)
(Yes, these count as bytes, the APL charset fits in a byte.)
I've claimed "display the game rules" and "count the number of turns".
G
n←32768-?65536
t←0
⎕←'Guess 16-bit signed number'
t+←1
→8/⍨n=g←⎕
⎕←⎕AV[(⌽⎕AV)⍳'×↑↑ ','○↑-' '∇⌊∘∇'⊃⍨1+n<g]
→4
⎕←'Congrats! You found the number in't'tries!'

Example run:
      G
Guess 16-bit signed number
⎕:
      0
TOO HIGH
⎕:
      -10000
TOO LOW
⎕:
      -5000
TOO LOW
⎕:
      -2500
TOO LOW
⎕:
      -1250
TOO HIGH
⎕:
      -1750
TOO LOW
⎕:
      -1500
TOO LOW
⎕:
      -1375
TOO LOW
⎕:
      -1300
TOO LOW
⎕:
      -1275
TOO LOW
⎕:
      -1265
TOO HIGH
⎕:
      -1270
TOO HIGH
⎕:
      -1273
 Congrats! You found the number in  13  tries!

Ungolfed:
GuessNumber;num;tries;guess;decode;too;low;high
decode←{⎕AV[(⌽⎕AV)⍳⍵]} ⍝ invert the character code, char 1 becomes char 255 etc.
num←32768-?65536 ⍝ select a random number
tries←0

⍝ strings for low/high
too←decode '×↑↑ '
low←decode '○↑-'
high←decode '∇⌊∘∇'

⎕←'Guess 16-bit signed number'

try:
  tries +← 1
  guess ← ⎕
  →(guess=num)/found
  ⍝ still here: number was wrong
  ⎕←too, (1+num<guess)⊃low high  ⍝ output appropriate word
  →try ⍝ try again
found:
  ⎕←'Congrats! You found the number in' tries 'tries!'

Pogo: -95 (255 - 300 - 50)
method main:void
    print("Guess the number. You will be told if you are high or low.")
    declare(integer,n,0)
    declare(integer,i,0)
    declare(integer,j,0)
    random() i
    while j != i
        set(n+1) n
        print("Number?")
        getinput() j
        if j > i
            print("High")
        end
        else
            print("Low")
        end
    end
    print("Yay" n "turns")
end main

If the number is 10:

Number?
5
Low
8
Low
12
High
10
Yay 4 turns

The character count is based on the code with all whitespace removed.
Note that Pogo is not a fake language. I created it and wrote a compiler and IDE for it here: https://github.com/nrubin29/Pogo

Read my EDIT and EDIT - 2

Updated as per the edits.


text:
ASCII-art logic gate diagram
I challenge you to write a code to make an (extended) ASCII-art logic gate diagram for the sum of products form of an equation.
Use the following notation to represent gates:

AND

    INPUT───|&&
            |&&───OUTPUT
    INPUT───|&&

OR

    INPUT───|OR
            |OR───OUTPUT
    INPUT───|OR

Gates with more than 2 inputs

    INPUT───|OR
            |OR
    INPUT───|OR───OUTPUT
            |OR
    INPUT───|OR

NOT

    INPUT───│>o───OUTPUT

Character set
Note that │ is not an ASCII pipe sign but a box-drawing character. Use box-drawing characters such as ─ │ ┌ ┐ └ ┘ for connections.
Example

Input

    A'*B'+B*C

Output

    A────│>o────│&&
                │&&─────┐
    B────│>o────│&&     └│OR
                         │OR─────A*B+B*C
    B───────────│&&     ┌│OR
                │&&─────┘
    C───────────│&&

Winner
The winner is the answer with the most up-votes in 5 days

There are only 95 printable ASCII characters, and they don't include any of these: ─ │ ┌ ┐ └ ┘. I think you're referring to the MS-DOS character set. Also, shouldn't your example have a single B input split between the two AND gates? And can we assume that there will be no need for wires to cross over anywhere?

I love how you say "STRICTLY an ASCII art" and require us to use a non-ASCII character set.

@squeamishossifrage I think there are 128 ASCII characters and 256 after extension of ascii chart visit here  http://www.juniper.net/techpubs/en_US/idp5.1/topics/reference/general/intrusion-detection-prevention-custom-attack-object-extended-ascii.html

@squeamishossifrage: No, he refers to some Extended ASCII characters. I've edited the question to clarify that. Extended ASCII includes all seven-bit ASCII characters, as well as some other characters.

@ProgramFOX He seems to refer to CP437

@mniip: The question poster took his image from the "Extended ASCII Codes" of http://www.asciitable.com/ so I'm pretty sure that he refers to Extended ASCII.

@ProgramFOX I don't know what "extended ascii" is, but it looks quite similar to CP437, with all respective consequences

@mniip: Wikipedia says: "The term extended ASCII (or high ASCII) describes eight-bit or larger character encodings that include the standard seven-bit ASCII characters as well as others." And you can see all those other characters on http://www.asciitable.com/

@ProgramFOX, if you read the sentence immediately after the one you've quoted, you'll see that your edit makes no sense.

@PeterTaylor: Ok, I've changed it into CP437.

Given the requirement to use box-drawing characters, it seems odd that you're making connections as ─│ rather than ─┤.

Can you even use CP437 on a Mac?

@JonathanVanMatre, there's probably some Unicode font with U25xx support.

Note that you can have pretty diagrams running this javascript code on this page : javascript:$('code').css({display:'block',lineHeight:'1em'})

@squeamishossifrage There can be multiple inputs for one variable refer to the diagram on page-5 here---http://seattlecentral.edu/faculty/mat119/text/LogicGates.pdf

C++11
Done at last. And it only took me most of the day.
Before I list the code and sample output, some quick notes:
Things this program does support

Any number of terms, each with any number of inputs
Reusing inputs
Omitting AND/OR gate representation when only one input would be present
Use of both codepage 437 line-drawing characters and 7-bit ASCII-friendly characters (use -DCP437 or whatever your compiler's equivalent is for codepage 437 support)

Things this program does not support

Grouping with parentheses (because, seriously?)
Multiple NOTing
Any whitespace that isn't a plain ASCII space
Proper golfification (although I did remove all the comments in spirit)
Sane coding practices
Making eye contact with the input parsing code
Portable, Unicode line-drawing characters. I couldn't support Unicode because the rendering logic relies on being able to draw "down" a two-dimensional char buffer.

Code
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <set>
#include <map>
#include <valarray>
#include <cmath>

using namespace std;

vector<string> split(const string str, const string delim)
{
    vector<string> v;

    set<char> d;
    for (char c : delim) d.insert(c);

    string current {};
    for (char c : str)
    {
        if (d.find(c) != d.end())
        {
            v.push_back(current);
            current = "";
        }
        else
        {
            current += c;
        }
    }
    v.push_back(current);

    return v;
}

using Input = string;
struct TermInput
{
    Input name;
    int ypos;
    bool neg;
};
using Term = vector<TermInput>;
using Expr = vector<Term>;

#ifdef CP437
constexpr char VERT    = '\xB3';
constexpr char HORIZ   = '\xC4';
constexpr char RBRANCH = '\xC3';
constexpr char LUP     = '\xD9';
constexpr char LDOWN   = '\xBF';
constexpr char RUP     = '\xC0';
constexpr char RDOWN   = '\xDA';
#else
constexpr char VERT    = '|';
constexpr char HORIZ   = '-';
constexpr char RBRANCH = '}';
constexpr char LUP     = '\'';
constexpr char LDOWN   = '.';
constexpr char RUP     = '`';
constexpr char RDOWN   = ',';
#endif

string repeat(string s, int n)
{
    stringstream ss;
    for (int i = 0; i < n; i++)
    {
        ss << s;
    }

    return ss.str();
}
string repeat(char c, int n)
{
    stringstream ss;
    for (int i = 0; i < n; i++)
    {
        ss << c;
    }

    return ss.str();
}

enum class Direction
{
    RIGHT,
    DOWN
};

void matrixPut(char *matrix, int h, int w, int x, int y, const string s, Direction dir)
{
    if (x >= w || y >= h)
    {
        stringstream ss;
        ss << "matrixPut: point (" << x << ", " << y << ") out of matrix bounds!";
        throw new out_of_range(ss.str());
    }

    char *ins = matrix + (y * w) + x;
    char *end = matrix + (h * w);
    for (char c : s)
    {
        if (ins >= end) break;
        *ins = c;

        if (dir==Direction::RIGHT)
        {
            ins++;
        }
        else
        {
            ins += w;
        }
    }
}

void matrixPrint(char *matrix, int h, int w)
{
    for (int i = 0; i < (h * w); i++)
    {
        cout << matrix[i];
        if ((i+1)%w == 0) cout << endl;
    }
}

int main (int argc, char *argv[])
{
    string expression;

    if (argc == 1)
    {
        cout << "Enter expression:" << endl;
        getline(cin, expression);
    }
    else
    {
        expression = argv[1];
    }

    expression.erase(remove(expression.begin(), expression.end(), ' '), expression.end());

    Expr expr {};
    auto inputs = set<Input>();
    auto termInputs = multimap<Input, TermInput>();

    int inputYPos = 0;

    auto e = split(expression, "+");
    for (string term : e)
    {
        Term currTerm {};

        auto t = split(term, "*");
        for (string in : t)
        {
            bool neg = false;
            if (in.back() == '\'')
            {
                in.pop_back();
                neg = true;
            }

            Input currInput {in};
            inputs.insert(currInput);

            TermInput ti {currInput, inputYPos, neg};
            currTerm.push_back(ti);

            termInputs.insert(pair<Input, TermInput>{in, ti});
            inputYPos++;
        }

        expr.push_back(currTerm);
        inputYPos++;
    }

    int height = inputs.size() + termInputs.size() + expr.size() - 1;

    int width = 0;

    width += max_element(inputs.begin(), inputs.end(), [](Input a, Input b){ return a.length() < b.length(); })->length() + 2;
    int inputWidth = width;
    width += inputs.size()*2;

    int notAndStart = width;

    width += 7;
    width += expr.size()+1;

    int orStart = width;

    width += 4;

    width += 4;

    width += expression.length();

    char matrix[height * width];
    for (int i = 0; i < height*width; i++) matrix[i] = ' ';

    int  baseY = inputs.size();

    {
        int x = width - 4 - expression.length();
        int y = baseY + ((height-baseY) / 2);
        matrixPut(matrix, height, width, x, y, repeat(HORIZ, 4) + expression, Direction::RIGHT);
    }

    {
        int x = orStart;
        int y = baseY + (height-baseY)/2 - expr.size()/2;

        if (expr.size() == 1)
        {
            matrixPut(matrix, height, width, x, y, repeat(HORIZ, 4), Direction::RIGHT);
        }
        else {
            matrixPut(matrix, height, width, x  , y, repeat(HORIZ, expr.size()), Direction::DOWN);
            matrixPut(matrix, height, width, x+1, y, repeat(VERT , expr.size()), Direction::DOWN);
            matrixPut(matrix, height, width, x+2, y, repeat('O'  , expr.size()), Direction::DOWN);
            matrixPut(matrix, height, width, x+3, y, repeat('R'  , expr.size()), Direction::DOWN);
        }
    }

    {
        int x = notAndStart;
        int y = baseY;
        for (Term t : expr)
        {
            string layer[7];
            for (TermInput ti : t)
            {
                layer[0] += HORIZ;
                layer[1] += (ti.neg ? '>' : HORIZ);
                layer[2] += (ti.neg ? 'o' : HORIZ);
                layer[3] += HORIZ;
                layer[4] += (t.size() > 1 ? VERT : HORIZ);
                layer[5] += (t.size() > 1 ? '&' : HORIZ);
                layer[6] += (t.size() > 1 ? '&' : HORIZ);
            }

            for (int i = 0; i < 7; i++)
            {
                matrixPut(matrix, height, width, x+i, y, layer[i], Direction::DOWN);
            }

            y += t.size() + 1;
        }
    }

    {
        int x = 0;
        int y = 0;

        for (Input i : inputs)
        {
            string str = i + ": ";
            str += repeat(HORIZ, inputWidth - str.length());

            matrixPut(matrix, height, width, x, y, str, Direction::RIGHT);

            y++;
        }
    }

    {
        int x = inputWidth;
        int num = 0;
        int offset = inputs.size() * 2 - 1;

        for (Input in : inputs)
        {
            int y = 0;
            int len = inputs.size() * 2 - 1;
            auto it = inputs.find(in);
            while (it != inputs.begin())
            {
                it--;
                y++;
                len -= 2;
            }
            matrixPut(matrix, height, width, x, y, repeat(HORIZ, len) + LDOWN, Direction::RIGHT);
        }

        for (Input in : inputs)
        {
            auto yBreakRange = termInputs.equal_range(in);
            valarray<int> yBreaks(termInputs.count(in));
            int idx = 0;
            for (auto ti = yBreakRange.first; ti != yBreakRange.second; ti++)
            {
                yBreaks[idx++] = baseY + ti->second.ypos;
            }

            for (int y : yBreaks)
            {
                matrixPut(matrix, height, width, x+offset, y, repeat(HORIZ, inputs.size()*2 - offset), Direction::RIGHT);
            }

            int y = num + 1;
            int maxBreak = yBreaks.max();
            string branch = repeat(VERT, maxBreak - y + 1);

            for (int i : yBreaks)
            {
                branch[i-y] = RBRANCH;
            }
            branch.back() = RUP;

            matrixPut(matrix, height, width, x+offset, y, branch, Direction::DOWN);

            offset -= 2;
            num++;
        }
    }

    {
        int x = notAndStart + 7;
        int outY = baseY + (height-baseY)/2 - expr.size()/2;
        int breakx = expr.size()/2;

        for (Term t : expr)
        {
            int inY = baseY + (t.front().ypos + t.back().ypos) / 2;

            matrixPut(matrix, height, width, x, inY, repeat(HORIZ, abs(breakx)+1), Direction::RIGHT);

            matrixPut(matrix, height, width, x+abs(breakx)+1, outY, repeat(HORIZ, expr.size()-abs(breakx)), Direction::RIGHT);

            if (inY < outY)
            {
                string branch = LDOWN + repeat(VERT, outY-inY-1) + RUP;
                matrixPut(matrix, height, width, x+abs(breakx)+1, inY, branch, Direction::DOWN);
            }
            else if (inY > outY)
            {
                string branch = RDOWN + repeat(VERT, inY-outY-1) + LUP;
                matrixPut(matrix, height, width, x+abs(breakx)+1, outY, branch, Direction::DOWN);
            }

            outY++;
            breakx--;
        }
    }

    cout << endl;
    matrixPrint(matrix, height, width);
    cout << endl;
}
Sample output
$ ./gates "A'*B'+B*C"

A: -----.
B: ---. |
C: -. | |
    | | `->o-|&&--.
    | }--->o-|&&  `-|OR
    | |          ,--|OR----A'*B'+B*C
    | `------|&&-'
    `--------|&&

$ ./gates "A*B'*C+B*D'+F*C'*D+G*E*A'+F"

A: -------------.
B: -----------. |
C: ---------. | |
D: -------. | | |
E: -----. | | | |
F: ---. | | | | |
G: -. | | | | | |
    | | | | | | }----|&&
    | | | | | }--->o-|&&---.
    | | | | }--------|&&   |
    | | | | | | |          |
    | | | | | `------|&&--.|
    | | | }------->o-|&&  ||
    | | | | |   |         |`---|OR
    | }--------------|&&  `----|OR
    | | | | `----->o-|&&-------|OR----A*B'*C+B*D'+F*C'*D+G*E*A'+F
    | | | `----------|&&  ,----|OR
    | | |       |         |,---|OR
    `----------------|&&  ||
      | `------------|&&--'|
      |         `->o-|&&   |
      |                    |
      `--------------------'
Sample output (with CP437 enabled)
A: ─────────────┐
B: ───────────┐ │
C: ─────────┐ │ │
D: ───────┐ │ │ │
E: ─────┐ │ │ │ │
F: ───┐ │ │ │ │ │
G: ─┐ │ │ │ │ │ │
    │ │ │ │ │ │ ├────│&&
    │ │ │ │ │ ├───>o─│&&───┐
    │ │ │ │ ├────────│&&   │
    │ │ │ │ │ │ │          │
    │ │ │ │ │ └──────│&&──┐│
    │ │ │ ├───────>o─│&&  ││
    │ │ │ │ │   │         │└───│OR
    │ ├──────────────│&&  └────│OR
    │ │ │ │ └─────>o─│&&───────│OR────A*B'*C+B*D'+F*C'*D+G*E*A'+F
    │ │ │ └──────────│&&  ┌────│OR
    │ │ │       │         │┌───│OR
    └────────────────│&&  ││
      │ └────────────│&&──┘│
      │         └─>o─│&&   │
      │                    │
      └────────────────────┘

+10 for sheer dogged determination :-)

That is not the output I wanted but, +1 for your hard-work(personally, I appreciate it).Also mention your language!

Kudos. This is very nice, CP437 or not.

I made a few edits to the post (not the code) based on the feedback above. I also got MinGW to work on my system so I could build it with native CP437 support, so I added some sample output form that.

On line 202 I get a compiling error in VisualExpress: int height and int width: Expression must have a constant value. Also you were missing #include <vector>

Oh, I fixed it by making the matrix a pointer with char * matrix = new char[height * width];

C++
Whew ! Done in 1 day 12 hrs!!!
This code handles array only
INPUT (TYPES)

Only SOP(sum of products) form.
Only addition of terms with two variables multiplying
EXAMPLES :-

    A*B'+B*A+C*D

    X*Y+Z'*A'*V*D+B*G+C'*A'

Can handle any number of terms,variables.
CODE :-
#include<iostream>
using namespace std;
int main()
{
int i,j,k,l,m=0;
char arr[80][80],expr[45];
cout<<"enter the SOP(Sum Of products) expression : ";
cin>>expr;
cout<<"\n\n";
for(i=0;expr[i]!='\0';i++)
if(expr[i]=='*')m++;
for(i=0;i<80;i++)
    for(j=0;j<80;j++)
        arr[i][j]=' ';
for(i=0,j=0;i<80,expr[j]!='\0';j++)
{
    if(expr[j]<=90&&expr[j]>=65||expr[j]<=122&&expr[j]>=97)
    {
        arr[i][0]=expr[j];
        i+=2;
    }
}
for(i=0,j=1;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j-1]<=90&&arr[i][j-1]>=65||arr[i][j-1]<=122&&arr[i][j-1]>=97)
    {
        for(k=0;k<7;k++)
            arr[i][j+k]=196;
        arr[i][j+k]=180;
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j]==(char)180&&arr[i][j+1]==' ')
    {
        arr[i][j+1]=38;
    }
}
for(i=0,j=0,k=1;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i-1][j]==(char)180&&arr[i+1][j]==(char)180)
    {
        if(arr[i-1][j+1]==(char)38&&arr[i+1][j+1]==(char)38&&k)
        {
            arr[i][j]=179;arr[i][j+1]=38;
            for(l=2;l<4;l++)
            {
                arr[i][j+l]=196;
            }
            k--;
        }
        else if(k==0)
        {
            k=1;
        }
    }
}
l=m;
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j-1]==(char)196&&arr[i][j+1]==' '&&arr[i][j-2]==(char)38)
        {
        if(arr[i+3][j-2]==(char)38)
        {
            for(k=0;k<l;k++)
                arr[i][j+k]=(char)196;
            arr[i][j+k-1]=(char)191;

            l--;
        }
        else
        {
            for(k=0;k<m;k++)
            arr[i][j+k]=(char)196;
        }
    }
}
for(i=0,j=0,k=1;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j]==(char)191&&arr[i][j-1]==(char)196)
    {
        for(;arr[i+k][j]==' ';k++)
        {
            arr[i+k][j]=(char)179;
        }
    k=1;
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j]==(char)179&&arr[i][j-3]==(char)38&&arr[i+1][j]==(char)196)
    {
        arr[i][j]=(char)192;
        for(k=1;arr[i-k][j+k]==(char)179;k++)
        {
            arr[i-k][j+k]=(char)192;
        }
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j-1]==(char)192)
    {
        for(k=0;arr[i][j+k]!=' ';k++)
            arr[i][j+k]=(char)196;
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j-1]==(char)192&&arr[i][j]==' '||arr[i][j-1]==(char)196&&arr[i][j]==' ')
    {
        arr[i][j]=(char)180;
        arr[i][j+1]='O';
        arr[i][j+2]='R';
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j-1]=='R'&&arr[i+1][j-1]==' ')
    {
        for(k=0;k<3;k++)
            arr[i][j+k]=(char)196;
        j+=k;
        for(k=0;expr[k]!='\0';k++)
        {
            arr[i][j+k]=expr[k];
        }
    }
}
for(i=0,k=0;i<80,expr[k]!='\0';k++)
{
    if((expr[k]<='z'&&expr[k]>='a'||expr[k]<='Z'&&expr[k]>='A'))
    {
        if(expr[k+1]=='\'')
            arr[i][1]='\'';
        i+=2;
    }
}
for(i=0,j=0;i<80;j++)
{
    if(j==80){i++;j=0;}
    if(arr[i][j]=='\''&&arr[i][j+1]==(char)196)
    {
        arr[i][j+3]=(char)180;
        arr[i][j+4]=(char)62;
        arr[i][j+5]='o';
    }
}
for(i=0;i<35;i++)
{
    for(j=0;j<80;j++)
        cout<<arr[i][j];
    cout<<'\n';
}
return 0;
}

OUTPUT

source: Stack Exchange

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

sort: votes


text:
Write a function that takes (x, y) and return x to the power of y WITHOUT Loops
This is a really neat short challenge.
Write a function or a procedure that takes two parameters, x and y and returns the result of xy WITHOUT using loops, or built in power functions.
The winner is the most creative solution, and will be chosen based on the highest number of votes after 3 days.

What sort of challenge is this?

@VisioN A think-out-of-the-box challenge, I suppose

How about exp(log(x)*y)?

I see you haven't read the cube root question. Is exp allowed? if so the answer is exp(ln(x)*y). Depending on the language you may have to protect for negative and zero x, but there are some that can handle it. I recommend you exclude exp specifically.

Even though the tag has been changed this question still has no objective winning criterion. [code-challenge] questions should have a method for scoring individual answers.

@nitro2k01, please note Gareth's point. Code challenge needs a winning criterion specified.

Is an answer for integers only acceptable? Since these are the first replies.

@steveverrill Does it have to have scoring, or just a winning criterion? The winning criterion would be to make a function that returns x to the power of y. I didn't expect the influx of answers using recursion as a way of getting around the need for loops. If that hole in the rules wasn't there, it would indeed be more of a challenge. I'm feeling that all of the answers so far are violating the spirit of the rules because of this.

@nitro2k01 See the code challenge page. "A code challenge is a competition...with an objective winning criterion not covered by other scoring tags." That means you have to define it. And it can't be yes/no, because that is "first valid answer accepted" which discourages competition. Some other tags, such as code golf (shortest code) or popularity contest (most votes) have an implied objective (and numeric) winning criterion (in addition to "complies with requirements.") Anyway, the OP has fixed it now. Spirit of rules can be decided by vote. A good non-recursive answer will get massive upvotes

Looks like the answers so far either use recursion or lists of repeated 'x's. I'm wracking my brains trying to think of another way (particularly something that allows a non-integer y).

@BenM mine is different, for example.

Unfortunately the prohibition on loops rules out fun mathematical solutions like Taylor expansion.

No loops? Sounds like a loophole (no pun intended) would be using recursion.

APL (7)
{×/⍵/⍺}

Left argument is base, right argument is exponent, e.g.:
     5 {×/⍵/⍺} 6
15625

Explanation:

⍵/⍺ replicates ⍺ ⍵ times, e.g. 5 {⍵/⍺} 6 -> 5 5 5 5 5 5
×/ takes the product, e.g. ×/5 5 5 5 5 5 -> 5×5×5×5×5×5 -> 15625

Hm.. This can be written in 5 characters in J, exactly the same method. */@$~

@Sieg 4 even, if you allow exponent on the left, base on the right.

I had the flip adverb because I thought it's not allowed.

@Seeq 4 in Dyalog APL: ×/⍴⍨

C#: Floating point exponents
OK, this solution is quite fragile. You can easily break it by throwing ridiculously huge numbers like 6 at it. But it works beautifully for things like DoublePower(1.5, 3.4), and doesn't use recursion!
    static double IntPower(double x, int y)
    {
        return Enumerable.Repeat(x, y).Aggregate((product, next) => product * next);
    }

    static double Factorial(int x)
    {
        return Enumerable.Range(1, x).Aggregate<int, double>(1.0, (factorial, next) => factorial * next);
    }

    static double Exp(double x)
    {
        return Enumerable.Range(1, 100).
            Aggregate<int, double>(1.0, (sum, next) => sum + IntPower(x, next) / Factorial(next));
    }

    static double Log(double x)
    {
        if (x > -1.0 && x < 1.0)
        {
            return Enumerable.Range(1, 100).
                Aggregate<int, double>(0.0, (sum, next) =>
                    sum + ((next % 2 == 0 ? -1.0 : 1.0) / next * IntPower(x - 1.0, next)));
        }
        else
        {
            return Enumerable.Range(1, 100).
                Aggregate<int, double>(0.0, (sum, next) =>
                    sum + 1.0 / next * IntPower((x - 1) / x, next));
        }
    }

    static double DoublePower(double x, double y)
    {
        return Exp(y * Log(x));
    }

"ridiculously huge numbers like 6"  I enjoyed that.

Surely use of Enumerable functions is relying on looping that was forbidden in the question or is it ok because the loop is inside framework methods?

C++
How about some template meta programming? It bends what little rules there were, but it's worth a shot:
#include <iostream>

template <int pow>
class tmp_pow {
public:
    constexpr tmp_pow(float base) :
        value(base * tmp_pow<pow-1>(base).value)
    {
    }
    const float value;
};

template <>
class tmp_pow<0> {
public:
    constexpr tmp_pow(float base) :
        value(1)
    {
    }
    const float value;
};

int main(void)
{
    tmp_pow<5> power_thirst(2.0f);
    std::cout << power_thirst.value << std::endl;
    return 0;
}

but this isn't a function, is a compile-time value, isn't it? :O

Well, a constructor is a function, and template parameters are almost like function arguments... right? =)

@PaperBirdMaster Yeah... that's why I admitted to some rule bending. I thought I was going to submit something besides tail-recursion, but I just submitted compile time tail recursion, haha. Close enough though, right?

@astephens4 close enough, I love it :3

Python
def power(x,y):
    return eval(((str(x)+"*")*y)[:-1])

Doesn't work for noninteger powers.

I like this one.

Why are you adding a separator without using join? eval('*'.join([str(x)] * y)).

Was this code-trolling?

Would like to also note that python has the ** operator, so you could've eval()d that.

@Riking: that'd be an inbuilt, though.

upvote for [:-1]

Python
If y is a positive integer
def P(x,y):
    return reduce(lambda a,b:a*b,[x]*y)

Haskell - 25 chars
f _ 0=1
f x y=x*f x (y-1)

Following Marinus' APL version:
f x y = product $ take y $ repeat x

With mniip's comment and whitespace removed, 27 chars:
f x y=product$replicate y x

use replicate y x instead of take y $ repeat x

I was convinced that you could save characters by writing your second function pointfree. As it turns out f=(product.).flip replicate is exactly the same number of chars.

@mniip It doesn't matter, this isn't code golf.

JavaScript (ES6), 31
// Testable in Firefox 28
f=(x,y)=>eval('x*'.repeat(y)+1)

Usage:
> f(2, 0)
1
> f(2, 16)
65536

Explanation:
The above function builds an expression which multiply x y times then evaluates it.

I'm surprised to see that nobody wrote a solution with the Y Combinator, yet... thus:
Python2
Y = lambda f: (lambda x: x(x))(lambda y: f(lambda v: y(y)(v)))
pow = Y(lambda r: lambda (n,c): 1 if not c else n*r((n, c-1)))

No loops, No vector/list operations and No (explicit) recursion!
>>> pow((2,0))
1
>>> pow((2,3))
8
>>> pow((3,3))
27

Uh, I've just seen right now KChaloux's Haskell solution that uses fix, upvoting him...

C# : 45
Works for integers only:
int P(int x,int y){return y==1?x:x*P(x,y-1);}

Beat me to it :-)  I think you could save a few bytes by writing return --y?x:x*P(x,y); instead

But this isn't [tag:code-golf]...

@oberon winning criteria was not clear when this was posted. Things have moved on.

@steveverrill Sorry.

Also in C# --y would be an int which is not the same as a bool like in other languages.

bash & sed
No numbers, no loops, just an embarrasingly dangerous glob abuse. Preferably run in an empty directory to be safe. Shell script:
#!/bin/bash
rm -f xxxxx*
eval touch $(printf xxxxx%$2s | sed "s/ /{1..$1}/g")
ls xxxxx* | wc -l
rm -f xxxxx*

"Preferably run in an empty directory to be safe." :D

Javascript
function f(x,y){return ("1"+Array(y+1)).match(/[\,1]/g).reduce(function(l,c){return l*x;});}

Uses regular expressions to create an array of size y+1 whose first element is 1. Then, reduce the array with multiplication to compute power. When y=0, the result is the first element of the array, which is 1.
Admittedly, my goal was i) not use recursion, ii) make it obscure.

Mathematica
f[x_, y_] := Root[x, 1/y]

Probably cheating to use the fact that x^(1/y) = y√x

Not cheating. Smart.

This is brilliant. Wish I'd thought of it for my R post.

Golfscript, 8 characters (including I/O)
~])*{*}*

Explanation:
TLDR: another "product of repeated array" solution.
The expected input is two numbers, e.g. 2 5. The stack starts with one item, the string "2 5".
Code     - Explanation                                             - stack
                                                                   - "2 5"
~        - pop "2 5" and eval into the integers 2 5                - 2 5
]        - put all elements on stack into an array                 - [2 5]
)        - uncons from the right                                   - [2] 5
*        - repeat array                                            - [2 2 2 2 2]
{*}      - create a block that multiplies two elements             - [2 2 2 2 2] {*}
*        - fold the array using the block                          - 32

Golfscript is always the way to go.

Ruby
class Symbol
  define_method(:**) {|x| eval x }
end

p(:****[$*[0]].*(:****$*[1]).*('*'))

Sample use:
$ ruby exp.rb 5 3
125
$ ruby exp.rb 0.5 3
0.125

This ultimately is the same as several previous answers: creates a y-length array every element of which is x, then takes the product. It's just gratuitously obfuscated to make it look like it's using the forbidden ** operator.

C, exponentiation by squaring
int power(int a, int b){
    if (b==0) return 1;
    if (b==1) return a;
    if (b%2==0) return power (a*a,b/2);
    return a*power(a*a,(b-1)/2);
}

golfed version in 46 bytes (thanks ugoren!)
p(a,b){return b<2?b?a:1:p(a*a,b/2)*(b&1?a:1);}

should be faster than all the other recursive answers so far o.O
slightly slower version in 45 bytes
p(a,b){return b<2?b?a:1:p(a*a,b/2)*p(a,b&1);}

For odd b, ~-b/2 == b/2.

@ugoren oh sure, you're right

This is a popular interview question :) "How can you write pow(n, x) better than O(n)?"

JavaScript
function f(x,y){return y--?x*f(x,y):1;}

Haskell - 55
pow x y=fix(\r a i->if i>=y then a else r(a*x)(i+1))1 0

There's already a shorter Haskell entry, but I thought it would be interesting to write one that takes advantage of the fix function, as defined in Data.Function. Used as follows (in the Repl for the sake of ease):
ghci> let pow x y=fix(\r a i->if i>=y then a else r(a*x)(i+1))1 0
ghci> pow 5 3
125

Q
9 chars. Generates array with y instances of x and takes the product.
{prd y#x}

Can explicitly cast to float for larger range given int/long x:
{prd y#9h$x}

Matching Golfscript in length is a feat to achieve.

Similar logic as many others, in PHP:
<?=array_product(array_fill(0,$argv[2],$argv[1]));

Run it with php file.php 5 3 to get 5^3

I'm not sure how many upvotes I can expect for this, but I found it somewhat peculiar that I actually had to write that very function today. And I'm pretty sure this is the first time any .SE site sees this language (website doesn't seem very helpful atm).
ABS
def Rat pow(Rat x, Int y) =
    if y < 0 then
        1 / pow(x, -y)
    else case y {
        0 => 1;
        _ => x * pow(x, y-1);
    };

Works for negative exponents and rational bases.
I highlighted it in Java syntax, because that's what I'm currently doing when I'm working with this language. Looks alright.

Pascal
The challenge did not specify the type or range of x and y, therefore I figure the following Pascal function follows all the given rules:
{ data type for a single bit: can only be 0 or 1 }
type
  bit = 0..1;

{ calculate the power of two bits, using the convention that 0^0 = 1 }
function bitpower(bit x, bit y): bit;
  begin
    if y = 0
      then bitpower := 1
      else bitpower := x
  end;

No loop, no built-in power or exponentiation function, not even recursion or arithmetics!

J - 5 or 4 bytes
Exactly the same as marinus' APL answer.
For x^y:
*/@$~

For y^x:
*/@$

For example:
   5 */@$~ 6
15625
   6 */@$ 5
15625

x $~ y creates a list of x repeated y times (same as y $ x
*/ x is the product function, */ 1 2 3 -> 1 * 2 * 3

Python
from math import sqrt

def pow(x, y):
    if y == 0:
        return 1
    elif y >= 1:
        return x * pow(x, y - 1)
    elif y > 0:
        y *= 2
        if y >= 1:
            return sqrt(x) * sqrt(pow(x, y % 1))
        else:
            return sqrt(pow(x, y % 1))
    else:
        return 1.0 / pow(x, -y)

** is built-in operator imo.

@SilviuBurcea True, editing.

@SilviuBurcea operator =/= function

@VisioN true, but the idea was about built-ins. I don't think the OP knows about all these built-in operators ...

Javascript
With tail recursion, works if y is a positive integer
function P(x,y,z){z=z||1;return y?P(x,y-1,x*z):z}

Bash
Everyone knows bash can do whizzy map-reduce type stuff ;-)
#!/bin/bash

x=$1
reduce () {
    ((a*=$x))
}
a=1
mapfile -n$2 -c1 -Creduce < <(yes)
echo $a

If thats too trolly for you then there's this:
#!/bin/bash

echo $(( $( yes $1 | head -n$2 | paste -s -d'*' ) ))

Mathematica
This works for integers.
f[x_, y_] := Times@@Table[x, {y}]

Example
f[5,3]

125

How it works
Table makes a list of y x's.  Times takes the product of all of them.`

Another way to achieve the same end:
#~Product~{i,1,#2}&

Example
#~Product~{i, 1, #2} & @@ {5, 3}

125

JavaScript  formerly 44   , now 41
f=(x,y)=>y?eval(Array(y).join(x+"*")+x):1

TESTING:
alert(f(5,3))
OUTPUT (alert): 125
alert(f(6,3))
OUTPUT (alert): 216
alert(f(8,0))
OUTPUT (alert): 1

Changes, altered logic to allow reversed execution, thus removing 3 characters...
Only works for positive integers

f(2,0) returns 2 instead of 1

A more ES6 solution: f=(x,y)=>{a=1;[x for (i of Array(y))].map(z=>a*=z);return a}

@Florent Corrected for x^0... And your ES6 solution unfortunately is using a for loop :/

Well, it’s a list comprehension. Is it closer to a loop than map?

I'm not using for nor am I using while, @minitech, plain and simple...

I didn’t say you were. What I said was that the for in Florent’s ES6 isn’t a for loop – it’s a list comprehension. I consider that a lot closer to map than a typical for.

Fair enough @minitech. :) +1 to you.

@WallyWest How about: f=(x,y)=>y&&(Array(y).join(x+",")+x).split(",").reduce((a,b)=>a*b,1)?

@WallyWest Your code doesn't work with 0 for y.

@toothbrush Give me a few moments, I had a flash of inspiration earlier this morning...

Scala - 47
def p(x:Int,y:Int)=(1 to y).fold(1)((a,b)=>a*x)

Not dissimilar to the other functional versions that use a variant of repeat or replicate, with the exception that it takes a lot of characters to repeat something in Scala (Stream.continually(x).take(y)).
This version iterates over the range of 1..y, but completely throws out the captured value at each step, instead multiplying the accumulator by the base value 'x'. I was originally going to use map to transform the range into all instances of the value x, and use the product function to multiply it, but this version is actually a bit shorter.
Usage
scala> def p(x:Int,y:Int)=(1 to y).fold(1)((a,b)=>a*x)
p: (x: Int, y: Int)Int

scala> p(5,3)
res44: Int = 125

C
Yet another recursive exponentiation by squaring answer in C, but they do differ (this uses a shift instead of division, is slightly shorter and recurses one more time than the other):
e(x,y){return y?(y&1?x:1)*e(x*x,y>>1):1;}

perl
Here's a tail recursive perl entry. Usage is echo $X,$Y | foo.pl:
($x,$y) = split/,/, <>;
sub a{$_*=$x;--$y?a():$_}
$_=1;
print a

Or for a more functional-type approach, how about:
($x,$y) = split/,/, <>;
$t=1; map { $t *= $x } (1..$y);
print $t

"a: stuff goto a if something" looks like a loop.

Yep, the goto version is a loop, but isn't tail recursion also essentially a loop?

Java 8
public long power(long num, int pow) {
    return LongStream.rangeClosed(1, pow).reduce(1, (i, j) -> i * num);
}

does not work with negative powers.

Python
def getRootOfY(x,y):
   return x**y

def printAnswer():
   print "answer is ",getRootOfY(5,3)
printAnswer()

answer =125

I am not sure if this is against the requirements, but if not here is my attempt.

Welcome to PPCG! When you do your language header you can leave out the "language=" since by custom everyone puts the language in the header so that's understood. You may indeed have run afoul of the rules here, but we'll let the voters decide. Glad to have a new member at the country club.

Windows Batch
Like most of the other answers here, it uses recursion.
@echo off
set y=%2
:p
if %y%==1 (
set z=%1
goto :eof
) else (
    set/a"y-=1"
    call :p %1
    set/a"z*=%1"
    goto :eof
)

x^y is stored in the environment variable z.

public static void main(String[] argv) {
    int v=getpow(4,3);
    System.out.println(v);
    }
public static int getpow(int b, int v) {
     if (v == 0) {
        return 1;
    } else {
        return b * getpow(b, v - 1);
    }
}

Java:
I/P: 3 and 4
O/P: 64

Simple recursive Python solution, works when y is non-negative integer:
def f(x, y):
    return 1 if y == 0 else x * f(x, y - 1)

ECMAScript 6 (32 bytes):
p=(x,y)=>y>2?p(x,--y)*x:+!y||x*x

Defines a function named p which takes x and y as parameters, and returns x to the power of y, without using any built-in functions, or loops.

It's important to return a precise answer, and to support large numbers -
public static BigInteger power(int x, int y) {
    return (y > 0) ? power(new BigInteger(String.valueOf(x)), y)
            : BigInteger.ONE;
}

public static BigInteger power(BigInteger x, int y) {
    return (y > 0) ? power(x, y - 1).multiply(x) : BigInteger.ONE;
}

public static void main(String[] args) {
    // From here
    // http://en.wikipedia.org/wiki/Power_of_two
    String result = "13,407,807,929,942,597,099,574,024,998,205,846,127,479,365,820,592,"
            + "393,377,723,561,443,721,764,030,073,546,976,801,874,298,166,903,427,690,"
            + "031,858,186,486,050,853,753,882,811,946,569,946,433,649,006,084,096";
    result = result.replace(",", "");
    System.out.println(result.equals(power(2, 512).toString()));
}

Of course, the output is
true

This isn't a code-trolling challenge.  You were supposed to return the value of x^y.

What do you think 2^512 is?

Oh, you overflowed the size of the BigInteger?

I was thinking it always returned true.

Javascript/HTML, cheater's (DIY) way:
function (a, b) { return "" + a + "<sup>" + b + "</sup>"; }

example run: http://jsfiddle.net/r4LfF/1/ (click "run" if it doesn't show up automatically)
maybe it can be done better, but I don't know Javascript!..

funny solution!

"Standard loopholes are not funny anymore"

@Jacob unfortunately, I have read this long after the solution was posted.

Don't worry about it :)

C, 79
This is an optimized version of the standard recursive call.  It refactors each successive call by powers of 2.  In other words if y is 2^n, it will be called n times.
typedef uint64_t Z;Z p(Z x,Z y){return(!y)?1:(1==y)?x:((y&1)?x:1)*p(x*x,y>>1);}

R
A cheap trick for positive integer-valued y:
hacky <- function(x, y) Reduce(`*`, rep(x, y))

And an approximation for real-valued y. As far as I'm aware, apply is not technically implemented as a loop:
mathy <- function(x, y, nterms) {
  sum(sapply(seq_len(nterms), function(i) Reduce(`*`, rep(y * log(x), i)) / factorial(i))) + 1
}

This one computed x^y=exp(y*log(x)) by taking the Taylor expansion of the right hand side. It can also be done recursively if you're leery of apply:
recursive <- function(x, y, nterms) {
  taylor <- function(n) {
    if(n==0) z <- 1
    else z <- Reduce(`*`, rep(y * log(x), n)) / factorial(n) + taylor(n-1)
    z
  }
  taylor(nterms)
}

And the coup-de-grace:
goofy <- function(x, y, nterms) {
  eval(parse(text = paste(
    sprintf("Reduce(`*`, (%s * log(%s))^%i) / factorial(%i)", y, x, 0:nterms, 0:nterms),
    collapse=" + "
  )))
}

I ran some single-run benchmarks for fun. Formatting them for looking pretty here is going to be more of a pain than it's worth, but I was surprised to see that the apply version was actually slower than the recursive version for small numbers of terms, and that their timings converged up to the maximum number of terms (171, the largest integer that factorial will accept). The text-based version was slower still for small numbers of terms, but was actually twice as fast for the large number of terms. They obviously fail dramatically compared to R's built-in versions.
Interestingly, it seems like R (or the package I'm using to benchmark, microbenchmark) does some magic in its innards, and when I set microbenchmark to use more than one trial all of the times drop by several orders of magnitude. The variation follows a similar pattern, but the differences are now in nanoseconds rather than logarithms of miliseconds.

Python
def pow (x, y):
    class Num:
        n = 1
        def __eq__ (self, v):
            Num.n *= v
            return False
    x in [Num()] * y
    return Num.n

x=2
y=3
print(pow(x, y))

Weirdo.

TI-BASIC
For TI-83/84 calculators
:Input X,Y
:Lbl 1
:Y-1->Y
:X*X->X
:If 1<Y
:Goto 1
:X

Displays/returns X

Pascal;
FUNCTION pwr(base,power:REAL):REAL;    // calculates base**power for base >0.0
BEGIN
  IF base > 0.0 THEN pwr := EXP(power*LN(base)) ELSE HALT(1);
END;

C++
Since most answers use some language quirks to get things done, i thought about trying to spice things up using quirks of data types themselves. Following function uses integer representation of IEEE float to get a logarithm approximation.
Blazingly fast and inaccurate.
float fapxpow(float x, float y) {
    __int32 lx = *(__int32 *)&x;
    lx = (lx - 0x3F7A7DD3)*y + 0x3F7A7DD3;
    float xy = *(float *)&lx;
    return xy;
}

R
f=function(x,y) prod(c(rep(x,y)))

Not super sure about 'prod', I didn't check how it's implemented. I might just be calling a loop here.

F#
Since ^ and ** were already taken and infix operators are fun, let's call it ^^
let rec (^^) (x: int) y =
  let fx = float x
  match y with
  | y when y < 0 -> (x ^^ y + 1) / fx
  | 0 -> 1.0
  | y -> (x ^^ y - 1) * fx

x and y are integers and it returns a float, since it handles negative exponents. Call it with x ^^ y

Delphi XE3
Uses a recursive function that will keep calling itself until multiplied according to the power.
Required input like p^o
var
  p,o:integer;

  function Pwr(n,r,c:integer):integer;
  begin
    if c=o then
      Result:=r
    else
      Result:=Pwr(n,r*p,c+1);
  end;
begin
    readln(p,o);
    Writeln(Pwr(o,p,1));
    readln;
end.

Input: 2 5
Output: 32

PHP
function altpow($x,$y) {
    if ( $y > 0 ) {
        return array_product(array_fill(0,$y,$x));
    } else if ( $y < 0 ) {
        return 1/array_product(array_fill(0,$y*-1,$x));
    }
    return 1;
}

Doesn't work with floating point exponents.
Test:
pow(4.33,-5) // 0.00065699266096183
altpow(4.33,-5) // 0.00065699266096183

Using C++
#include <iostream>

using namespace std;

float power(float x, float y) {
    if(y  == 0)
    return 1;
    if(y == 1)
    return x;

    return power(x,y-1) *x;

    }

int main()
{
   cout << "Hello World" << endl;

   cout<<power(2,3);

   return 0;
}

Clojure
(defn pow [x y]
 (if (= y 0) 1
  (reduce * x (take (- y 1) (repeat x)))))

(pow 2 2)
=> 4

It will not work for negative exponent.

Perhaps you could add an explanation of how it works?

Also, it doesn't seem to work for 2, 0, 0, 0, or 2, -2.

This is a little overcomplicated. (defn pow [x y] (if (<= y 0) 1 (reduce * (repeat y x)))) works just fine. @toothbrush It takes list of x repeated y times and returns the product ((reduce * [1 2 3]) == 1 * 2 * 3)

@Sieg Yes, but x to the power of 0 is always 1.

@toothbrush That is why the if-clause is there. See, if the first argument is true (that being (<= y 0) which is more traditionally y <= 0), then it returns the second argument (that being 1). Otherwise it returns the third argument, which is the product.

Java 8 lambda recursion
    static BinaryOperator<Integer> powerof;
public static void main(String[] args) {
    powerof = (x, y) -> {return y == 0 ? 1 : x * powerof.apply(x, y-1);};
    System.out.println(powerof.apply(5, 3));
}

Guess it's kind of late, but I'll post anyway to celebrate the imminent release of java 8 :)

Another Mathematica Solution, 33 characters
D[ExpIntegralEi[(1 + y) Log[x]], x, y]

I believe that this does not violate the rule against using "built in power functions", as while the exponential integral function implies E^t dt, it does not involve x^y.
This solution is unusual among those posted here in that it works for more than just positive integers, and in fact works for any complex numbers for both x and y.

C
int power(int x,int y)
{
if ( y!=1 )
    return (x*power(x,y-1));
}

What is this illegal?

what if condition not true ?? no return

@Omer the question didn't specify that the function should work for all x and y. For instance none of the functions would work for y<=0. I could add a condition to work for y==1. But I don't see any need for it currently.

@user689 My answer handles all valid ECMAScript numbers (whole and floating-point; negative and non-negative).

Python
import math
def recurse_log(x, minimum, cur):
    val = math.log(cur, x)
    if cur == minimum:
        return (val,)
    else:
        return recurse_log(x, minimum, cur-1) + (val,)

def exp(x,y):
    crude_ans = 1<<(int(y*math.log2(x)))
    min_ans = crude_ans//2
    max_ans = crude_ans*2
    possible = list(recurse_log(x, min_ans, max_ans))
    return min_ans + min(range(len(possible)), key=lambda v: abs(possible[v]-y))

Works only with integers. This code finds a crude calculation of the answer using log base two and a bitshift (which serves as a base 2 exponents). This gives an answer accurate to the nearest power of two. Then, it takes the log of every integer in the possible range and sees which is closest.
It's very very slow.

Interesting idea, but "WITHOUT Loops" vs. for i in range ?

@DigitalTrauma I guess list comprehensions count as loops. I changed it to use a recursive function, but that hits Python's recursion limit for large numbers.

JavaScript, ES5+
This may be bending the rules a bit, due to the use of forEach, although it's not being used in the typical fashion.
function pwr(x, y){
  var array1 = [], i = 0, result = 1;
  array1.push(function(){i++; result *= x; if(i >= y) throw {};});
  array1.push(function(a){array1.forEach(a)});
  try{
    array1.forEach(array1[1]);
  }
  catch(e){
    return result;
  }
}
console.log(pwr(3,4)); //81

y must be an integer; x does not need to be.

Jelly - 3 bytes
x×/

Pretty much identical to the APL and J solutions, but as a newer language Jelly is more efficient.
x turns a,b into [a,a,...,a] (length b)
×/ computes reduce(c,d-->c×d, [a,a,...,a]), to get a×a×...×a = a^b.

F# (.NET Core), 42 bytes
fun(x,y)->Seq.reduce(*)<|Seq.replicate y x

Try it online!

authors: Татьяна Горошко

all_licenses: 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/