text:
Calculator that adds char values
Task
Build a calculator, that takes any string, from a file, stdin or whatever, and adds up all the values of the chars.
Example
Input
Hello World!

Output
1085

Rules
The calculator needs to accept just ASCII encoding.
The shortest code wins.
Notes
Regarding to the comment of m.buettner, I need to say, I didn't thought of the multibyte part.
So I leave it as a bonus thing aswell.
The calculator should be run as written, so no need to modify before compiling or interpreting.
Bonus
Thanks to Synthetica, here is one more bonus,

The program that has the lowest output when you use its code as its input wins gets a star.

I don't want to modify it completly.
If you write it additional to output the (right) value in UTF-8 you get a star.
The code that executes fastest on my Laptop (Lenovo Yoga 13 Intel Core i5 3317U 1.7Ghz, 8GB RAM, 128GB SSD, Intel HD 4000, Windows 8) gets a star.
Web codes will run first under IE11 with chakra and then in FireFox 29.0.1 with SpiderMonkey
Linux code will run on a Raspberry Pi with Raspbian.
The teststring is this:
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(

Have fun coding :)
Bonusscoring
I plan to do the scoring at this Saturday so the 07.06.14, all answers after that date won't get bonus points ;)
You can download the code I gonna use for testing here feel free to fork and improve it :)
Little update because of the bonus, my laptop is partially broken so I will do it probably next weekend, I am really sorry for that :(

[tag:code-golf] and [tag:fastest-code] are conflicting win criteria, you need to choose one of them.

@KyleKanos I changed it, I chose code-golf, cause fastest-code is just a bonus ;)

I get 1085 for Hello World! using two different languages for ASCII values on my computer.

@KyleKanos Damn, I forgot the bang at the end...

He probably forgot to add the '!'. edit you were 3 seconds faster...

@m.buettner I didn't thought of that, I edited the task a bit.

Could one please explain the downvotes?

My guess is that the downvotes indicate that it's not really a good problem.

@KyleKanos could you explain why you think that it could be not a good problem? It is my first code-golf, I would like to improve ^_^

@Knerd mainly, because it's a bit too trivial in most languages (as you can see from the length of the submissions you already got)

@m.buettner Good to know, so more heavy golfs than easy ones I guess. I'll keep that in mind :)

It's kind of a shame that you forgot the huge oppurtunity for a great special code golf: the program that has the lowest output when you use its code as its input wins

@Synthetica damn, you are good :D I think I gonna add this as a bonus :)

Full program, or just a function?  e.g. http://codegolf.stackexchange.com/a/30232/11259 vs http://codegolf.stackexchange.com/a/30230/11259

@DigitalTrauma it should run like it is written so no adjustments needed

What is a "star"? Is it advantageous? Do that reduce my byte count, or make me win in the event of a tie?

Could the input contain a null byte?

GolfScript, 4 characters
{+}*

Simply uses the fold operator (*) to add up all the characters.
If it has to work with the empty string, 9 chars:
{{+}*}0if

Thanks to @PeterTaylor for providing an alternative 6-char version that works with empty string:
0\{+}/

Does not work on the empty string.

@Howard Good point; edited.

0\{+}/ supports empty string

@Doorknob sorry for the stupid question, how to I input data? I use http://golfscript.apphb.com/

@Knerd You can download the interpreter and pipe input into it, or you could just use a string literal in the online version to mimic STDIN.

@Knerd E.g. like in this example.

@Howard Thanks for the example, I was nearly stuck :/

\{+}/ what sort of emoticon is this?

@immibid A cyclops with a weirdly shaped eye. :-P (or, in GolfScript, the "swap-and-add-each" face!)

@Doorknob don't forget that the cyclops is excited and or rejoicing! There is a reason he is waving his \ / arms around like that!

APL (8)
+/⎕UCS⍞

Explanation:

+/ sum of
⎕UCS unicode values of
⍞ character input

What would be the result for Hello World!?

@Knerd: 1085. It wouldn't be correct if it gave another output. It sums the values of the Unicode codepoints of the characters.

ok, I didn't got what the ⍞ means ;)

@knerd: ⍞ means read a line from the keyboard

Do you know an APL interpreter that is free?

@knerd NARS2000

OP allows input from "whatever", so you don't need the final ⍞. This would make it an unnamed atop (2-train), which could be named or parenthesized before applying to a character string.

Haskell 36
main=interact$show.sum.map fromEnum

From where does it read the text?

stdin. $ printf "Hello World!" | ./charsum

ok, I couldn't get it run on my Windows machine, I gonna try it on the rpi when I am at home

When I execute your code, I just get the string "Hello World!" as Output. This is my commandline: ECHO "Hello World! | ghci charsum.hs

You are missing a quote it seems.

Oh sorry, the quote is in, I forgot to type it -_- But that doesn't change the result.

D:\tests>type hw.txt     Hello World!     D:\tests>type hw.txt | sum.exe     1085

use interact and show instead of getContents>>=print: main=interact$show.sum.map fromEnum

Thanks for reminding me of interact. The worst part is that it's right under getContents, which I purposefully looked up in hoogle...

Shell+GNU tools, 29 bytes
echo `od -An -tuC`|tr \  +|bc

Takes input from stdin:
$ printf "%s" 'Hello World!' | ./addchars.sh
1085
$

Own score: 2385

c, 52 bytes
c;main(p){while(~(p=getchar()))c+=p;printf("%d",c);}

Compile with (some warnings produced):
gcc addchars.c -o addchars

Takes input from stdin:
$ printf "%s" 'Hello World!' | ./addchars
1085 $

Own score: 4354

This is great answer. CodeBlocks with GNU compiler always complains if variables have no type e.g int c, main(int p). So I think these should be included in your answer.

@bacchusbeale I added a note about compilation warnings, but I think this is generally par-for-the-course when golfing in c.  As long as the code compiles and runs as expected, then warnings can be ignored.  See http://codegolf.stackexchange.com/a/2230/11259 and http://codegolf.stackexchange.com/a/2204/11259.  Of course production code is a different matter entirely.

@DigitalTrauma are all those spaces actually necessary? Can the Shell not ignore the whitespace and use the - to mark new parameters?

@AshwinGupta Are you talking about the od command? od -AntuC does not do the same as od -An -tuC.

@DigitalTrauma yeah I was. I meant couldn't you do od-An-tuC or od -An-tuC

@AshwinGupta Have you tried it?  od-An-tuC is parsed as one token, and -An-tuC will be passed as one arg, which programs don't typically attempt to parse further due to all the potential ambiguities

@DigitalTrauma nah I can't try I have Windows not Linux shell.

Javascript (ES6)  51
alert([...prompt(x=0)].map(y=>x+=y.charCodeAt())|x)

@nderscore Can you explain what the ... before the prompt does? Is this a new ES6 thing or is it pre-ES6?

@WallyWest It's called a spread operator and it's part of the ES6 draft.

@nderscore So If I'm understanding the spread operator syntax, your use of [...prompt(x=0)] has taken the prompt with a default value of 0 (which goes later to be used in the sum), and applies that input as an array of characters...? Which technically would be the same as prompt(x=0).split(""), right?

@WallyWest prompt(x=0) means "set x to 0, call prompt with the value of setting x to 0", which is to say, 0. It would be equivalent to write (x=0,prompt(x))

8086 Assembly (16-bit) - 47 41 bytes
The contents of the test.com file are:
98 01 c3 b4 01 cd 21 3c 0d 75 f5 89 c7 c6 05 24
89 d8 b1 0a 4f 31 d2 f7 f1 80 ca 30 88 15 09 c0
75 f2 89 fa b4 09 cd 21 c3

Actual work is done in the first 11 bytes; I need the rest to print the result in decimal notation.
Source code (give as input to the DOS debug.com assembler):
a
; input the string; count the sum
    cbw
    add bx, ax
    mov ah, 1
    int 21
    cmp al, d
    jne 100
; Prepare for output: stuff an end-of-line marker
    mov di, ax
    mov [di], byte 24
    mov ax, bx
    mov cl, a
; 114
; Divide by 10; write digits to buffer
    dec di
    xor dx, dx
    div cx
    or  dl, 30
    mov [di], dl
    or  ax, ax
    jne 114
; Print the string
    mov dx, di
    mov ah, 9
    int 21
    ret

rcx 29
n test.com
w
q

Some notes on the code:

Only handles one line (up to end-of-line character 13); hangs if no end-of-line
Only 7-bit characters are supported (results are incorrect otherwise)
Outputs 0 for empty input
Cannot handle output greater than 64K
Instruction at address 0x10d overwrites itself (pure coincidence)
Have to use DOS emulators like DosBox to assemble and run this program

How can you understand that? o.O

Love the brutality of just writing the output right into your code :)  BTW, You can -2 bytes in the "Prepare for output" section by replacing mov di, ax with xchg ax, di and also mov ax, bx with xchg ax, bx. Nice work!

You could also use si instead of di for the output buffer pointer since on all mainstream versions of DOS si is initialized to 100h by default saving one my byte by removing the xchg ax, di.

OR (last one I promise) you could use bx for your pointer and move mov cl, 0ah and xchg ax, bx above mov byte ptr [bx], '$' and it'll use the 0x10d address as you had it before. Same 38 byte size as above though.

gs2, 1 byte
d

d (0x64 / sum), of course, sums up all bytes in standard input.

Ruby, 13 12 bytes
p~9+gets.sum

sum is a built-in function that sums the characters of a string. Subtracts 10 to account for the newline at the end of gets's return value.
(Edited 4 years later to change x-10 to ~9+x... the value of ~9 is -10, but it lets us remove the space between p and its argument, saving a byte.)

I am not familiar with Ruby at all, could you explain your code please?

gets is a function that reads a string from standard in until a newline is read, it returns a String.  String#sum adds the values of each character, which returns a Fixnum.  Fixnum#- is just subtraction. p is a method for outputting the debug value of something on a line.

CJam, 3 bytes (sum 260)
q1b

You can try it online.
Thanks jimmy23013 for helping chop off 2 characters :)
Explanation:
q     read the input into a string
1b    convert from base 1, treating each character as its numeric value

q1b is shorter.

Python 3 - 28 bytes
print(sum(map(ord,input())))

Example run:
$ ./sum_string.py <<< 'Hello World!'
1085

Gets input from stdin, maps the ord function to it to get the ASCII value of each character, sums it and prints.

Ninja'd, I had the exact same idea. +1 for that.

@TheRare So did I, even though mine was longer, because I used Python 2.7. I'm getting rusty ;)

@Synthetica I always use Python 2.7, on which the answer would have been print sum(map(ord,raw_input()))

@TheRare Which was my exact answer ;)

Nitpicking here, but you can make it perform better by changing map(ord,input()) to input().encode(). Bytes objects can still be summed, and it stays the same length.

Befunge98, 6 bytes, sum: 445
2j@.~+

Any interpreter should be fine. I use CCBI.
Use as follows:
printf 'Hello World!' | ccbi calc.fg

Works for multibyte chars and empty strings.
Explanation

2j - jump over the next two instructions (@ and . - see below)
~ - put the next char on the stack
+ - add the code value of the new char to the current sum. The instruction pointer wraps to the beginning and the cycle repeats
when ~ encounters an EOF it inverses the direction of the pointer and the two "hidden" instructions are executed:
. - print the sum
@ - exit

Python, 24 bytes
This is shorter than any Python solution so far: an unnamed anonymous function, which takes the string as an argument, and returns the sum.
lambda x:sum(x.encode())

Try it online!
First, x.encode() transforms it into a bytes object. Then, sum adds the char-code values. As this is a lambda function, the value is implicity returned.
Additionally, one could have lambda x:sum(map(ord,x)) for the same byte count.

Julia - 11 7 characters, resultant sum = 943 536
Since the question allows the input to come from whatever source you want, I choose an existing variable. Assume that A contains the string we wish to evaluate.
sum(A)1

As it turns out, you can sum the string directly, and it will evaluate... however, due to the way that summing of chars is handled, if there is an odd number of characters in the string, it will output a character, rather than an integer of any sort. As such, we force it to cast to int by multiplying by 1.
Old version:
sum(A.data)

Will output in a hexadecimal notation (if the sum is less than 256, it'll be 0x??, otherwise it'll be 8 byte as 0x????????). If used in code where the result is used, it will operate just like any other number (it's just how Julia displays unsigned ints).
To see the value of the result in decimal, enclose the above in int(), as in int(sum(A.data)).
For anybody who doesn't know Julia, you assign to A exactly the same way you do other assignments to variables. So, A="Hello World!" or A="sum(n.data)". In the case where you need to put in " or ' characters, there are multiple options, the easiest of which (because it avoids need for knowledge of the nuances of Julia string literals) is A=readline(), followed by simply typing in the string into STDIN (won't handle newlines, though). The escape sequence for newline is, as usual, \n, but I don't believe you can use that with readline().

+1 for the god damn clever solution ^^ Could you post, how to assign the test value to the variable n? I don't know Julia at all ;)

@Knerd - I've edited it in. Hope that helps.

Great, thank you. I try to test it later :)

Minor change - switched variable from n to A to reduce the resultant sum from 988 to 943.

OK, much bigger change - I realised that you can sum the string directly, rather than extracting the characters with .data; but because they're characters, they produce a character result for an odd number of characters. Multiplication by 1 corrects that.

Go (59 characters)
func d(s string)(t int){for _,x:=range s{t+=int(x)};return}

Everything in Go is utf8 by default. Codetext in ` delimeters run through itself gives an output of: 5399.

I have to say I'm rather surprised there's no math.Sum for use with map or similar

PowerShell - 27
[char[]]$args[0]|measure -s

Example
> SumChars.ps1 'Hello World!'

Count    : 12
Average  :
Sum      : 1085
Maximum  :
Minimum  :
Property :

26 if you use [char[]]"$args"|measure -s as long as there is only one $arg entry.

SML, 42 36
Just adding another language.
fun$x=foldl op+0(map ord(explode x))

Converts String to char array, calculates ascii number of each value and calculates the sum of all ascii numbers.

You can drop some spaces and the leading ;. 36 bytes: https://tio.run/##DcpBCoAgEAXQq0zRQomiC7ivdYuWEWgRfB2xKby9uXzwHo/BQziUcr6hy@ZkWBDHflL@iMTJKpcj2DrKWpfvAO0mpjuIWoKMwqtUXKqjdnYA08YJtmnr/QE

K5, 2 bytes (function), 5 bytes (program)
Function
+/

Program
+/0:`

Not sure if K5 was created before or after this challenge was posted. Regardless...THIS IS AWESOME!!
In K5, if you perform arithmetic operations on strings, it converts the characters to their ASCII codes. So this just uses the sum operator +/ (actually, it's plus + over).

Matlab/Octave 4 bytes (bonus: 405)
This code is an anonymous function, that does the job, it will take a string, and return the required number.
@sum

I am not sure about the gs2 answer, but at least with the same approach as the Julia answer, I should still write sum(A). I think sum alone is not ok (wouldn't even be valid code=).

Javascript ES6, 41 bytes
_=>[..._].map(y=>x+=y.charCodeAt(),x=0)|x

Thanks to @ETHproductions for 2 bytes saved!

How about _=>[..._].map(y=>x+=y.charCodeAt(),x=0)|x?

Gol><>, 4 bytes
iEh+

Is it pronounced like 'Golfish?'

@cat Yes, it's golfish.

@randomra is that "gol•fish" or "golf•ish"? As in a fish with gol, or something kind of like golf?

Jolf, 2 bytes
Try it here!
ui
u  sum of
 i  the input string

Umm... I don't know what else to say.

Vyxal, 2 bytes
C∑

Try it Online!
Explained
C∑
C  # char
 ∑ # sum

J (7)
So close, yet so far... Oh well, I guess 7 is decent enough, since this answer also accepts empty strings. (I'm basing my usage of a variable as input on the phrase from a file, stdin or whatever)
+/a.i.b

Explanation:
a.

┌┬┐├┼┤└┴┘│─ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~��������������������������������������������������������������������������������������������������������������������������������

a. contains all ASCII chars.
   'people' i. 'pow'
0 2 6

x i. y is similar to python's [x.index(i) for i in y].
   a. i. 'Hello World!'
72 101 108 108 111 32 87 111 114 108 100 33

Therefor, a. i. y converts y to an array of its ASCII values
   +/1 2 3 4 5 6
21

+/ is like sum: +/1 2 3 4 5 6 means 1+2+3+4+5+6
   +/ a. i. 'Hello World!'
1085

The whole thing in action
For the bonus:
   b=:'+/a.i.b'
   +/a.i.b
482

Not bad, I guess.
   b=:'0\{+}/'
   +/a.i.b
478

Well, darn.
   A=:'+/a.i.A'
   +/a.i.A
449

Thanks @algorithmshark
    A=:'+/3 u:A'
    +/3 u:A
413

Thanks @marinus

+1 for the great explanation. One little question, where can I best execute J?

@Knerd From the makers (http://jsoftware.com/) I guess, I don't know any online interpreters. (Fun fact: they have an official console for Android.) http://www.jsoftware.com/download/j801/

@Synthectica That is cool :D Now I need an Android smartphone :P

Renaming b to A results in a score of 449.

@algorithmshark Oh, right! I'll claim that star for now ;)

3 u: has a lower score (258) than a.i. (294)

@marinus I'll add that, thanks.

JavaScript (ES6) 54 58

alert([].reduce.call(prompt(),(v,c)=>v+c.charCodeAt(0),0))

    54 bytes thanks to nderscore:
alert([...prompt()].reduce((v,c)=>v+c.charCodeAt(),0))

Works good, I tried it by now in http://es6fiddle.net

You could just use Firefox ;)

I was at work so :D

54: alert([...prompt()].reduce((v,c)=>v+c.charCodeAt(),0))

Got it down to 51 now :) alert([...prompt(x=0)].map(y=>x+=y.charCodeAt())|x)

Cool! But I think you should post it as your own answer. It's not my idea, but yous... And it's very clever ;)

C 32
f(char*s){return*s?*s+f(s+1):0;}

main(int argc,char **argv){return(argc?main(0,&(argv[1])):(**argv?**argv+main(0,argv)+((*argv)++?0:0):0));} (107 chars) though it ignores the first character for some reason. Also, POSIX exit codes are only 8 bits; in bash, echo $?.

the rules were a little bit broad so i didn't use main. i'll work on something shorter maybe

@bebe I changed the rules a bit, to make it clear what is needed ;)

D (function: 60)
Definitely not in it to win it.
Assuming it doesn't need to be a complete program
int c(string i){int s;foreach(e;i){s+=cast(int)e;}return s;}

Called like so
void main ()
{
    import std.stdio;
    auto hw = "Hello World!";
    writefln("%s = %d", hw, c(hw));
}

Output:
Hello World! = 1085

D (program: 133)
Does not count line breaks.
void main(){import std.algorithm,std.stdio;stdin.byLine.map!((a){int s;foreach(e;a){s+=cast(int)e;}return s;}).reduce!"a+b".writeln;}

With more whitespace and longer variable names for readability
void main () {
    import std.algorithm, std.stdio;

    stdin.byLine
        .map!((line) {
                int sum;
                foreach (ch; line) {
                    sum += cast(int)ch;
                }
                return sum;
            })
        .reduce!"a+b"
        .writeln;
}

To support line breaks in the input, I could either use byLine(KeepTerminator.yes) — the correct way, for 20 characters — or append a '\n' to my line — which breaks single-line input and may give the wrong sum on Windows because of CRLF, for 18 characters.

+1 for posting even if you know, that you won't win

R, 35 characters (sum of 3086) 26 bytes (sum of 2305)
sum(utf8ToInt(readline()))

readline() is one character longer than scan(,"") but scan split the input on spaces by default.
Usage:
> sum(utf8ToInt(readline()))
Hello World!
[1] 1085
> sum(utf8ToInt(readline()))
sum(utf8ToInt(readline()))
[1] 2305
> sum(utf8ToInt(readline()))
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
[1] 14835

Delphi (87 83)
function x(s:string):int64;var c:char;begin x:=0;for c in s do x:=result+ord(c)end;

Ungolfed
function x(s:string):int64;
var
  c:char;
begin
  x:=0;
  for c in s do
    x:=result+ord(c)
end;

Loops through S adding the ord value of the char to the result. where x==result
Edits:
Saved 4 characters by switching to int64 and changing the adding to the sum.

Do you have a free version of Delphi (insert you version here) availiable?

Hm.. Not really sorry. But I can explain un-golfed what happens where and do some testcases if you want.
Free pascal has more or less the same syntax so you could do that.

Ok, I gonna check that out.

k (8 chars)
+/6h$0:0

Q translation
sum `int$read0 0

Bonus value:
k)+/6h$0:0
+/6h$0:0
438i

Java 8 - 79 bytes
interface C{static void main(String[]a){System.out.print(a[0].chars().sum());}}

Japt, 6 bytes
U¬mc x

Pretty simple. Try it online!
How it works
U¬mc x  // Implicit: U = input string
U¬      // Split U into chars.
  mc    // Map each item to its char code.
     x  // Sum.
        // Implicit: output last expression

Out of curiosity, why didn't you assign ¬ to a negation of some sort?

@CᴏɴᴏʀO'Bʀɪᴇɴ Because I was in a hurry and just assigned them as I saw need, without planning ahead. I have a set that makes more sense ready to be rolled out, by changing one line of code, but I'm leery about that because it'd invalidate nearly every existing answer.

That's an easy fix. Add a conditional to the header (e.g., url/interpreter.html#new=1); anything without it uses the old character set, and anything with it uses the new character set.

@CᴏɴᴏʀO'Bʀɪᴇɴ Thanks, I'll consider that.

PlatyPar, 2 bytes
us

Try it online!
u generates an array of all charcode values in the input string, and s finds their sum.
When run on itself, it returns 232.
This is similar to Conor's Jolf answer, except that I use a byte to convert the string into an array of character codes (which is implicit in Jolf), whereas he uses a byte to retrieve the input (which is implicit in PlatyPar).

JavaScript function golf, 77 bytes
var s=i();var x=0;for(var i1=0;i1<sl(s);i1++){x+=schca(s,i1);}console.log(x);

I made this for you!
Yes, you got it right, it's my own function golf again. It recently got a string functions update.
The language was created after the challenge, so it's non-competing.
Validity source:
>>> var s=i();var x=0;for(var i1=0;i1<sl(s);i1++){x+=schca(s,i1);}console.log(x);
Hello World!
1085

Bonus score:
>>> var s=i();var x=0;for(var i1=0;i1<sl(s);i1++){x+=schca(s,i1);}console.log(x);
var s=i();var x=0;for(var i1=0;i1<sl(s);i1++){x+=schca(s,i1);}console.log(x);
6276

Java 8, 113 chars
BigInteger C(String s){BigInteger i=BigInteger.ZERO;s.chars().forEach(x->i=i.add(BigInteger.valueOf());return i;}

Note each character in Java is Unicode 1-4 bytes unsigned integer, using sum function would easily overflow.
Detailed
BigInteger C (String s)
{
    BigInteger i = BigInteger.ZERO;

    s.chars().forEach(x -> i = i.add(BigInteger.valueOf(x));

    return i;
}

Java 8, 57 chars
ASCII only solution
int C(String s){return s.chars().filter(x->x<128).sum();}

Detailed try here
public static int C (String s)
{
    return s
        .chars() // stream the characters
        .filter(x -> x < 128) // filter ASCII (optional)
        .sum(); // return the sum
}

Maybe you misunderstood -- you must work with at least ASCII, so there is no reason for you to filter ascii.

@cat I fixed it now, the solution wouldn't work for unicode since int would easily overflow even if you just sum two characters with higher than 2^32 / 2

101 bytes including BigInteger import. Also, your current submission fails to compile (variable referenced in lambda must be final or effectively final)

18 bytes for the (unfiltered) ascii-only version

Unipants' Golfing Language, 8 bytes
cIl+I:_o

Try it online!
Returns 660 given its own source code.
Explanation
cIl+I:_o
c        # Create an integer. We need it - you'll see why.
 I       # Input the first character.
  l  :   # While loop.
   +     # Add the character value to the integer. This is
         # why we needed an integer. Otherwise, there would
         # only be 1 item in a stack now, and the "+" op is
         # not defined for this case. In fact, it returns 0
    I    # Input the next character.
      _  # Discard a zero (the zero from the last input,
         # representing the End Of Line).
       o # Output the result.

JavaScript (ES6), 37 bytes
f=([c,...a])=>c?c.charCodeAt()+f(a):0

This uses a handy feature, new in ES6: destructuring assignments. When run, the variable c gets set to the first char in the string, and a gets set to the rest of the string as an array.

Cubix, 10 bytes
OU@;i)!^(+

Test it online!
This is almost the perfect challenge for Cubix, which can only input one char code at a time. This code expands to the following cube net:
    O U
    @ ;
i ) ! ^ ( + . .
. . . . . . . .
    . .
    . .

The code is then run, starting at the i and facing east. Here's the main loop:

i - input a char code from STDIN and push it to the stack. Pushes -1 on EOF.
) - increment the top item.
! - if the top item is non-zero, skip the next instruction.
( - decrement the top item.
+ - add the top two items. Note: the stack has infinite zeroes at the bottom.
. - no-op.

When EOF is reached, the ! fails, and ^ forces the instruction pointer to move north onto the top face. Then this code is run:

; - pop the top item (currently a 0).
U - turn 180 degrees counter-clockwise. This is used to fit ;O@ on the top face.
O - output the top item (sum of char-codes) as a number.
@ - terminate the program.

I think ..;Oi?.@/+ works for the same byte count (and less instructions :P )

@Flp.Tkc That doesn't work on null bytes though, although perhaps "The calculator needs to accept just ASCII encoding" means it won't ever need to

Minkolang, 6 bytes
$o$+N.

Try it online!
Explanation
$o         takes all characters from input as chars (the characters are automatically
           converted to their character codes)
$+         sum up all the values
N.         output as number and end program

PHP, 46 bytes
No PHP answer on this yet, so here's the easy one:
<?=array_sum(array_map(ord,str_split($argn)));

Try it online!
$ echo Hello World!|php -F addascii.php
1085

More non-competing answers:
48 bytes
Iterative:
foreach(str_split($argn)as$s)$x+=ord($s);echo$x;

Try it online!
51 bytes
Iterative 2:
while($i<strlen($argn))$x+=ord($argn[$i++]);echo$x;

Try it online!
63 bytes
Recursive:
function f($s,$c=0){return$s?f(substr($s,1),ord($s[0])+$c):$c;}

Try it online!
69 bytes
Using PHP's rarely used [citation needed] array_reduce() function:
<?=array_reduce(str_split($argn),function($c,$i){return$c+ord($i);});

Try it online!

05AB1E, 2 bytes
ÇO

Try it online.
Explanation:
Ç   # Convert each character in the (implicit) input to its unicode value
 O  # Sum this list of integers
    # (after which the result is output implicitly)

Keg, 2 bytes
?⅀

Try it online!
Explanation
?  # Read the full input string
 ⅀ # Sum the whole stack
# Implicit output

2 bytes

W, 2 bytes
The Join function also works with numbers.
CJ

W, 4 bytes
Terribly golfed answer...
C@+R

Fig, \$1\log_{256}(96)\approx\$ 0.823 bytes
S

Try it online!

imagine my disappointment when I scroll down

Lua 57
a=io.read();b=0;for i=1,#a do b=b+a.byte(a,i)end print(b)

Sucks that it's the longest by a long shot, but whatever.

C# in LINQPad, 28
Console.ReadLine().Sum(i=>i)

Will it execute as it is written? See the notes ;)

Edited and fixed.

Won't execute, you are missing the using System; part.

Ok, since I'm a LINQPad-addicted, I tend to forget those envrionment things. I decided to edit the title ;) and I think now it works just fine.

Yeah, should work. For the speed test I gonna add the environment stuff ;)

C 63
main(a,b)char**b;{a+=*b[1];*b[1]++?main(a,b):printf("%d",a-2);}

Compileonline is giving me Segmentation fault (core dumped). Any tips?

@tolos: Yes, it expects input as a command line argument which ideone won;t support

Is this acutal C? Which IDE/Compiler are you using? Visual Studio 2013 doesn't accept it.

I compiled with VS2012, yet to install 2013. Note, you actually have to compile as a C Program not as a C++ to make this work

Ok, didn't know that. I gonna try it as C programm later.

Perl 33
$_=<>;$x+=ord for split'';print$x

I don't know Perl too well.  I'm sure it can be golfed some more.

Nice short answer.  Think needs a chomp somewhere though, as gives 1095 as answer to Hello World! instead of 1085.

Cobra - 81
class P
    def main
        c,d=Console.readLine,0
        for i in c,d+=i to int
        print d

J (9 chars)
In the REPL, we only need 6 chars:
   +/a.i.'Hello World!'
1085

To make it a re-usable program, we need to add 3 chars of decoration:
   as=: [: +/ a.&i.
   as 'Hello World!'
1085

Common Lisp, 35
(reduce'+(read-line):key'char-code)

Produces 3053 when given its own code.

jq, 12 characters
(11 characters code + 1 character command line option.)
explode|add

Sample run:
bash-4.3$ bin/jq -R 'explode|add' <<< 'Hello World!'
1085

On-line test (Passing -R through URL is not supported – so input passed as string "Hello World!".)
(CW because explode appeared in jq 1.4, released 4 days after this question.)

><>, 19 bytes
0i:1+?!v+!
    ;n~<

It does work on Unicode. For example, this correctly outputs 27272
: ⚳ℚ⊻
Try it here

I don't think that this deserves its own answer, so here's a 14 byte version (split into two lines): ii:0(7$.+!, ~n;. 0 in place of i would work, too. An alternate 17 byte version of yours would be ii:0(?v+!, ;n~< (again, in two lines - this time without whitespace on the second)

Perl, 34 32 27 25 21+1=22 bytes
Added 2 due to the need for -p flags.  Thanks to @manatwork for the guidance.
$a+=ord for/./g;$_=$a

Test:
echo 'Hello World!' | perl -pe '$a+=ord for/./g;$_=$a'
1085

No need for parenthesis around the statement modifier's expression. And no need to explicitly assign the input to $_ – after all, that makes it default variable. $a+=ord for<>=~/./g;print$a

As both -n and -p cost the same 1 character, better use the later and replace print$a → $_=$a.

Perl 22
s/./$t+=ord$&/eg;say$t

sample:
perl -nE 's/./$t+=ord$&/eg;say$t'  < <(echo -n Hello\ World\!)
1085

Java, 144 bytes (sum of 13067)
interface S{static void main(String[]A){int I=0;for(char J:new java.util.Scanner(System.in).nextLine().toCharArray())I+=J;System.out.print(I);}}

Mathematica, 19 bytes
Tr@*ToCharacterCode

Test case:
Tr@*ToCharacterCode@"Hello World!"
(* 1085 *)

 2, 5 chars / 13 bytes
⨭ ᴉ⒨⒞

Try it here (Firefox only).
Splits and maps the input to its charcodes, then sums the resulting array.

C++, 131 140 bytes

Golfed:
#include<iostream>
int main(){int a=0;std::string x;getline(std::cin,x);for(int c=0;c<x.length();c++){a=a+(int)x[c];}std::cout<<a;}

Ungolfed:
#include<iostream>

int main(){
    int a = 0;
    std::string x;
    getline(std::cin, x);
    for(int c = 0; c < x.length(); c++){
        a = a + (int) x[c];
    }
    std::cout<<a;
}

Java, 139 Bytes
//takes input from cmd line args
class P {public static void main(String a[]){String s=a[0];int v=0;for(int i=0;i<s.length();i++){v+=(int)s.charAt(i);}System.out.print(v);}}

It's big, but yeah.

Mathcad, 11 "bytes"

Uses Mathcad's built-in vector summation operator.   As "whatever" is an input method, the user types the word directly into the argument for the function str2vec (which converts a string to a vector of its character codes).

Factor, 3 bytes
sum

Strings are sequences, arrays of char values. sum is basically 0 [ + ] reduce (or, equivalently, [ + ] foldl), so this sums the chars in a string.

Mathcad, 13 "bytes"

Uses built-in vector summation operator and string-to-vectorOfCharacterCodes function. Definition operator ":=" entered by single key ":", summation operator by ctl-4.

Python 3, 37 bytes
print(sum([ord(c) for c in input()]))

There's a shorter one, but this is possible as well. It converts the string into a list will all the ASCII values of the characters and adds them together using sum().
Star version, 55 bytes
a=sum([ord(c) for c in input()]);print(a);print(chr(a))

Now gimme my gold star.

FWIW: There's an useless whitespace before for.

Clojure, 31 bytes
#(reduce +(map int(read-line)))

Really straightforward. Gets its input from stdin, works with Unicode.

Hoon, 18 bytes
|*
*
(roll +< add)

This is a wet gate, so that I don't have to specify tape instead of *. This has the added bonus of it being fully generic, so it could actually accept (list @ud) too. Wet gates typecheck at the call site, instead of definition.
+< is the sample of the gate, indexed into the sample with tree navigation syntax because it's shorter than naming the function arguments. |*(a/* a) is longer than |*(* +<).
> %.  "Hello World!"
  |*
  *
  (roll +< add)
b=1.085

Unfortunately, this doesn't work correctly as-is with unicode. Urbit's string literals are lists of UTF8 chars. You can use ++tuba to convert it to UTF32, though.
> %.  "⚳ℚ⊻"
  |*
  *
  (roll +< add)
b=1.622

> %.  (tuba "⚳ℚ⊻")
  |*
  *
  (roll +< add)
b=27.272

Pushy, 2 bytes
S#

Try it online!
Input is automatically converted to charcodes and placed on the stack. S sums the stack, and # prints it.

Brainfuck - 15 Bytes
,[>,]<[[<+>-]<]

Try it here (You have to click the box marked "!")
Put your input after the exclamation point. (not necessary but allows easy EOF.)
What it does
,[>,]     take input as characters in separate cells until input has ended (automatically in ascii)
<         go to the last character
[         infinite loop
[<+>-]    add the last character and the character before it and save it as the last character
<]        go back to the last character and then do the infinite loop again

Unfortunately, it exits with an out of memory error and does not print the output, but that wasn't part of the challenge. If you want to see the output, read the tape. It also only goes up to 255 on this interpreter. (if anyone knows an interpreter with larger cells that exits on error, that would be great)

The counter overflows if you input something such as Hello World!...

Kotlin, 22 bytes
(String) -> Int lambda.
{it.sumBy{it.toInt()}}

Try it online!

Runic Enchantments, 10 bytes (Self-sum: 703)
iul1)?@+2?

Try it online!
It has a limit on how long of a string it can handle. For a version that can handle any length string:
/l͍:i0< /~~@
R1-:0≮?/:}}:{%3s}+}

Try it online! (Self-sum: 3937)
In both cases spaces need to be escaped in order to be read as a single input. The first one works by unconcatening the string and iteratively adding each character together until only a single value is left (printing it).
The second uses an index pointer and extracts one character at a time, adding it to a running total (requiring more in the way of setup and stack manipulation).

Japt -mx, 1 byte
c

Try it!

If the input cannot be an array of chars, then this can be done in 3 bytes:
¬xc

Try it!

Perl 5 -pF, 15 bytes
Under the rules in place at the time of this challenge, I believe it would have been +3 for the command line flags, giving a score of 18.

map$\+=ord,@F}{

Try it online!

Whitespace, 61 bytes
[S S S N
_Push_0][N
S S N
_Create_Label_LOOP][S N
S _Duplicate_top][S N
S _Duplicate_top][T N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve_input][S N
S _Duplicate][S S S T   S T S N
_Push_10][T S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_PRINT][T    S S S _Add][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_PRINT][S N
N
_Discard_newline][T N
S T _Output_top_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Since Whitespace inputs one character at a time, the input should contain a trailing newline so it knows when to stop reading characters and the input is done.
Try it online (with raw spaces, tabs, and new-lines only).
Explanation in pseudo-code:
Integer s = 0
Start LOOP:
  Integer c = Read STDIN as character
  If(c == 10) // c == '\n'
    Call function PRINT
  s = s + c
  Go to next iteration of LOOP

function PRINT:
  Discard the top of the stack (the 10 / newline)
  Print s as integer to STDOUT

C# (Visual C# Interactive Compiler), 14 bytes
s=>s.Sum(x=>x)

Try it online!

Unexpended Sinclair ZX80 - 65 tokenized BASIC bytes
 1 INPUT A$
 2 LET A=0
 3 IF A$="" THEN GO TO 7
 4 LET A=A+CODE(A$)
 5 LET A$=TL$(A$)
 6 GO TO 3
 7 PRINT A

There are a few caveats, without POKEing some (or one, I don't recall) memory location(s), all maths is done via 16-bit signed integers, so the range is -32768 to +32767, so any string entered that is too long will overflow the VAR stack and break the program. Also, the ZX80 character set is not ASCII compatible and there is no exclamation mark, so HELLO WORLD (as there are no lower-case characters by default either) is 494 - source.
BASIC does not update the screen whilst doing calculations and such, so after entering the string it will take some time to work out where nothing will be displayed. Your original string entered in the A$ variable will not show.

Ahead, 5 bytes
SK+O@

S      slurp input
 K+    reduce stack by summing
   O   output sum
    @  end

Try it online!

@, 4 bytes
Seems like a perfect task for @.
Σš

Explanation
Σ  Summation of
 š a one-line input

Brain-Flak, 6 bytes (own code sum: 577)
({{}})

Try it online!
Seems to be a good challenge for Brain-Flak.
Explanation:
 {  }   while top of Stack is not 0, calculate sum of
  {}    pop value
(    )  push calculated sum
        implicitly output the Stack

Wren, 35 bytes
The fact that they aren't doing this in Wren is a perfect chance for me.
Fn.new{|x|x.bytes.reduce{|a,i|a+i}}

Try it online!
Explanation
Fn.new{|x|                        } // New anonymous function with parameter x
          x.bytes                   // Convert x to its bytecode forms
                 .reduce{|a,i|a+i}  // Sum this bytecode form

Pyth, 3 bytes
sCM

Try it online!
Alternatively, smC works as well.
Explanation:
    # implicit output
s   # sum(                )
  M #     map(   ,       )
 C  #         ord
    #             input()   -> implicit input

K (ngn/k), 2 bytes
+/

Try it online!
In K, a string is basically a list of ASCII char codes, so just the sum adverb will do the job.

Go, 58 bytes
func f(b[]byte)(s int){for _,e:=range b{s+=int(e)}
return}

Attempt This Online!

Raku, 10 bytes
*.ords.sum

Try it online!
The ords string method conveniently returns a list of the ordinal values of the characters.

Thunno 2 SB, 0 bytes

Attempt This Online!
Or, 2 bytes flagless:
CS

Attempt This Online!

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:
Calculate the square root only using ++
Your task is to calculate the square root of a positive integer without using any mathematical operators to change the number, such as:

Setting a variable (ex. squareRoot = 5)
Addition (A+B)
Subtraction (A-B)
Multiplication (A*B)
Division (A/B)
Square, cube, fourth, etc. roots
Exponents

Comparison operators (such as <, >, ==, etc) are not considered "mathematical operators" for the purposes of this question and are allowed as long as they do not change the value of a variable.
The only operator that you are able to use is ++.  The following exceptions are in place:

If you wish, you may initialize a variable by setting it to 0.
If your language does not include the ++ syntax, you may use an equivalent syntax, such as foo+=1 or foo=foo+1
The square root should be calculated to at least 6 digits beyond the decimal (the hundred-thousands place) and outputted as a whole number of the decimals (ex. if I input 2 it could come out as 14142135624 or 1414213 depending on the rounding).  Rounding up or down is not important.

User-defined functions are not allowed.  In addition, simulating functions with goto is not allowed as well.
I'm interested to see what everyone submits!  Happy coding!
CLARIFICATION
Clarify that number is a positive integer.  You are welcome to make code that would do any number but it is not necessary.
CLARIFICATION #2
Clarify that comparison operators are allowed.
CLARIFICATION #3
Addition, subtraction, multiplication, division, and functions to change numbers are not allowed at all, regardless of whether they are saved to a variable or not.  I'm sorry that this invalidates a couple existing answers, but I meant to define this group of operators with "change the number" in order to prevent troll answers (ex. I just used the sqrt() function, you only prohibited addition, multiplication, division, and subtraction).  Sorry for the confusion.
CLARIFICATION #4
Clarify that we need at least 5 digits.  10 digits caused code to run for a long time.

Are comparisons such as < and > disallowed operators?

Comparisons are fine, however the only operation that can change the value of a variable (or constant, I suppose) are ++ and --, with the exceptions listed above.

Are bitwise operators allowed? And to clarify, is -- allowed or not... as it isn't stated in the question, but in your comment you mentioned it.

Nope, -- is not allowed, sorry for the confusion!  I originally planned to have ++ and -- but I decided to take -- out at the last minute.

@iggyvolz ... and bitwise?

"without using any mathematical operators to change the number" - I think this might need clarification. Do you mean that these operators may not be used at all, or, that they may be used, but only if the result isn't saved to a variable, e.g. while r*r<n*10e20:r+=1 - fairly trivial. Also, you might consider reducing the required output to 10^8 or so. First, because 10^10 is larger than 2^31, and second, because it will take a while to increment that high.

Why would you ever want to "change" any variable at all? You imperative guys have strange ways of thinking...

Are we allowed to do, say, i=1? That is, can we initialise a variable that will then be incremented?

@leftaroundabout 'static variable' is self-contradictive.

@Ourous - oh sorry, missed that part.  If the function in itself changes the value of any variable, it is not allowed.

@primo - I'll reduce it to 10^8, but answers with 10^10 will still be allowed

@GlenO - "If you wish, you may initialize a variable by setting it to 0." You can do i=0, but not i=1.  If you needed i=1, you could always do i=0;i++;

I am flagging to close this question. To much radical changes to the question. You should actually get this question validated through Sandbox or else you would frustrate people investing effort to answer.

Reducing the number of required digits is meaningless without time/memory limits. My code can handle 5 digits, but my machine doesn't have enough RAM.

Python 66
print'%.0f'%reduce(lambda a,b:abs(a)+1e10j,range(-2,input())).real

Output
>>> print'%.0f'%reduce(lambda a,b:abs(a)+1e10j,range(-2,input())).real
121
110000000000
>>> print'%.0f'%reduce(lambda a,b:abs(a)+1e10j,range(-2,input())).real
1000
316227766017

 This solution uses Spiral of Theodorus on a complex plane to achieve the result.

I think that will need to be wrapped in int(...*1e10), otherwise very nice. Although, taking abs of a complex value is more or less sqrt in disguise.

@primo I don't think you're allowed the *1e10 ...

@primo: Instead of multiplying by 1e10, I took a bit different route. And though I agree that abs may be sqrt in disguise, yet I feel its completely legal as currently stated in the problem.

I see a downvote, and its quite depressing. I had high hope for this answer, so any one who downvoted, please leave back a comment.

This doesn't follow the new clarification.  Sorry about invalidating your answer, but I meant to say that these functions were not allowed at all, not just to modify a variable.

@iggyvolz: I am really surprised that you keep on expanding your question and adding more restrictions. People invest time and effort to write an answer and you can;t expect them to be psycic.

I tried running as a py file and it says syntax error. In the interpreter it runs OK. Output without %d is 1.1e+11 and with %d output is 1099999999.

@bacchusbeale: I tried running as a py file and it says syntax error., not sure what error you are getting. This runs fine in ideone. Regarding, your o/p as 1099999999, there was a rounding issue which I have now fixed.

Python, 184 characters
The following Python solution uses only the increment operator and no other arithmetic operators at all. However, with the required precision (10 digits), it takes an impossibly long time to run. You can test it with lower precision (3 digits) by reducing 1e20 to 1e6.
import sys;t=0
for _ in range(int(sys.argv[1])):
 for _ in range(int(1e20)):t+=1
q=0
while 1:
 z=0
 for _ in range(q):
  for _ in range(q):z+=1
 if z>=t:break
 q+=1
print(q)

Ungolfed:
import sys

# t = N * 100000000000000000000 (magnitude of twice the precision)
t = 0
for _ in range(int(sys.argv[1])):
    for _ in range(int(1e20)):
        t += 1
q = 0
while True:
    # z = q * q
    z = 0
    for _ in range(q):
        for _ in range(q):
            z += 1
    if z >= t:
        break
    q += 1
print(q)

I clarified the question, you can do it to as many digits as you want (at least 5).
I'm not familiar with python, but I'm assuming that int() is just a type caster?  If so, that is fine because it doesn't change the value of the number.

@iggyvolz: Right, you need that to convert the string argument value (specified on the command line) to an integer. A plain function wouldn't need that.

Fortran 73
read*,t;s=0;do while(abs(s*s/1e10-t)>1e-10);s=s+1;enddo;print*,s/1e5;end

Might take a loooong to actually determine an answer for certain values, but it'll work for sure. While I use * and -, these are not changing any values, only the s=s+1 actually changes anything.

Wow, guess I didn't think about using operators for changing static values.  That's perfectly fine and +1 (if I had 15 reputation to upvote)

This uses the * operator, which is pretty clearly not permitted. Or am I somehow misunderstanding the given restrictions?

@GregHewgill: OP states, without using any mathematical operators to change the number; these operators are not changing any values.

I guess then I don't understand what is meant by the number - which number? Just the one that is the input to the program?

@GregHewgill: We're to compute sqrt(t) by only incrementing some other variable, s, until s*s=t; my assumption is that "number" means s.

But that's still using the * operator to change a number, you're just not saving the result anywhere. If the OP wanted to simply disallow assignments (other than s=s+1), then why mention all the disallowed arithmetic operators?

@GregHewgill: Nothing I did is explicitly against the specs, though I agree I'm bending it a little. OP said my answer is perfectly fine (because he didn't think about using operators for changing static values), I'm content with that.

So then what does changing static values mean? The usual definition of static means that something doesn't change. What are you changing that doesn't change?

@GregHewgill: I think that the question is poorly specified; this answer of mine reflects the poor nature of the question by abusing one aspect of the rules (that you can only change a variable by incrementing it). Any analysis of this particular answer is moot, IMO.

This doesn't follow the new clarification.  Sorry about invalidating your answer, but I meant to say that these functions were not allowed at all, not just to modify a variable.
Yeah, sorry about my earlier comment, I was half asleep when I made that.

@iggyvolz: Changing the rules ~20 hours later is bad form. Please do not do that and use the sandbox to work out the kinks in your problem instead.

CJam, 26 bytes
q~,1e20,m*,:N!{)_,_m*,N<}g

Try it online. Paste the Code, type the desired integer in Input and click Run. Before you do, I suggest changing 1e10 to 1e4 though.
The Java interpreter handles 1e6 with input “2” in about 15 seconds. 1e20 will require a huge amount of RAM.
Examples
$ cjam <(echo 'q~,1e2,m*,:N!{)_,_m*,N<}g') <<< 4; echo
20
$ cjam <(echo 'q~,1e2,m*,:N!{)_,_m*,N<}g') <<< 2; echo
15
$ cjam <(echo 'q~,1e4,m*,:N!{)_,_m*,N<}g') <<< 4; echo
200
$ cjam <(echo 'q~,1e4,m*,:N!{)_,_m*,N<}g') <<< 2; echo
142
$ cjam <(echo 'q~,1e6,m*,:N!{)_,_m*,N<}g') <<< 4; echo
2000
$ cjam <(echo 'q~,1e6,m*,:N!{)_,_m*,N<}g') <<< 2; echo
1415

Background
Since we're not allowed mathematical operators to change numbers, we're going to use setwise operators to change arrays.
The code starts by "multiplying" the input (“i”) by 1e20, but without any  actual multiplication. Instead, we push an array containing “i” integers, an array containing 1e20 integers, take their cartesian product and compute its length.
Then, we push zero and increment until the product of the integer by itself (calculated as above) is no longer smaller than i * 1e20. This causes the square root to be rounded up.
How it works
q~     " Read for STDIN and interpret. ";
,      " Push an array containing that many integers. ";
1e20,  " Push the array [ 0   …   1e20 - 1]. ";
m*,:N  " Get the length of the cartesian product and save it in “N”. ";
!      " Logical NOT. Since the input is a positive integer, this pushes 0. " ;
{      " ";
  )    " Increment the integer on the stack.";
  _,   " Push an array containing that many integers. ";
  _m*, " Get the length of the cartesian product of the array by itself. ";
  N<   " If the product is smaller than the target value, push 1; otherwise push 0. ";
}g     " Repeat the loop if the result was 1. ";

Cobra - 62
Posted before the third edit, no longer valid.
Not only is it short, but it should be overflow-free if n < Decimal.maxValue

def f(n)
    r,e=0d,10000000000
    while r/e*r/e<n,r+=1
    print r

But you used r/e*r/e, which is clearly a non-++ math operator...

@nneonneo this was posted before the third edit, and I haven't changed it yet

Scala, 117
val z=BigInt(readLine+"0000000000")
print(Stream.from(1)find(x=>(BigInt(0)/:Stream.fill(x,x)(1).flatten){_+_}>=z)get)

Doesn't finish in a reasonable amount of time, even for 2 as input, but it does work. You may notice that I'm doing _+_, but that only ever adds 1, and Scala doesn't have a ++ operator anyway. I could save two characters by replacing the inner Stream with List, but then it would run out of memory. As written, I think it scales only in processing time, not memory usage.

PHP, 124 bytes
It's an exhaustive algorithm. It just tries numbers until the square of that number is bigger than the "goal" number (which is the input times 1Enumber of decimals squared (10.000 for a 2 decimal result). Then it prints that last number.
for(;$a++<$z=$argv[1];)for(;$$a++<1e6;)$g++;for(;$b++<$g;$i=$x=0)for(;$i++<$b;)for($j=0;$j++<$b;)if(++$x>=$g)break 3;echo$b;

Run like this (-d added for aesthetic reasons only):
php -d error_reporting=32757 -r 'for(;$a++<$z=$argv[1];)for(;$$a++<1e6;)$g++;for(;$b++<$g;$i=$x=0)for(;$i++<$b;)for($j=0;$j++<$b;)if(++$x>=$g)break 3;echo"$b\n";' 2

Don't recommend trying this out with anything more than 3 decimals or a number above 10.

Haskell, 70 bytes
s i|r<-[1..i]=foldl1(.)[(+1)|j<-r,k<-r]
f i=[j-1|j<-[0..],s j 0>=i]!!1

f gives the integer square root by finding the largest number whose square is less than or equal to the input. The squaring function s i increments by one for every element of an (i,i) matrix. (Typed on phone so might have typos).

x86-64 Assembly Code, 22 bytes
No operators or function calls, as per the rules.
// Int from stack -> st0
fild 8(%rsp)
// sqrt(st0) -> st0
fsqrt
ret

Expects argument pushed onto the stack, then call this function, like so:
push $2
call a

The result is saved onto the register stack (%st0). Tested on MinGW64.

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


text:
Evaluate a Linear Feedback Shift Register
Introduction
The Fibonacci Linear Feedback Shift Register (LFSR) is a digital circuit which generates a stream of random-looking bits.  It consists of several 1-bit flip-flops in a row, with certain positions designated as 'tapped'.  In each iteration, the values in the tapped positions are XORed together (i.e., summed modulo 2) and the result is held in reserve.  Then the bits are shifted to the right.  The rightmost bit falls off the register and becomes the output, while the reserve bit is input on the left.
Maximal LFSR
The output stream of a LFSR is periodic; it repeats after some number of iterations.  A maximal LFSR has a period of 2^n - 1, where n is its number of bits.  This only occurs if the tapped positions are correctly chosen; otherwise the period will be less.  If the LFSR is maximal, it will cycle through all possible internal states (except all zeroes) exactly once before repeating.
For more information about maximal Fibonacci LFSRs (primitive polynomials), see this article:  https://en.wikipedia.org/wiki/Linear_feedback_shift_register#Fibonacci_LFSRs
Task
You must write a function that takes as its arguments a list representing the initial internal state of an n-bit LFSR (a list of length n made of 0 and at least one 1), and a list of tapped positions.  The tapped positions are input as a list with either of these general formats (brackets, commas, and spaces are shown for convenience and are entirely optional):
Format A:  [0, 0, 1, 1]
Format B:  [3, 4]
Both formats declare that the 3rd and 4th positions are tapped.
The function must produce exactly one complete cycle of output of the LFSR (either as function output, or printed to the screen), as well as a Boolean evaluation of whether or not the LFSR period is maximal.
If you prefer, you may use two functions to produce the LFSR output and maximality evaluation.
Scoring
Per usual code golf rules, your score is the number of characters in your code.  Make sure your code evaluates these examples correctly:
Example 1
State: [1, 0, 1, 0]
Taps:  [3,4]
Output:  [0,1,0,1,1,1,1,0,0,0,1,0,0,1,1] and True (since the period is 2^n - 1 = 15)
Example 2
State:  [1, 0, 1, 0, 1]
Taps:  [3, 5]
Output:  [1,0,1,0,1,0,0,0,0,1,0,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,1,1,0,1,1] and True (since the period is 2^n - 1 = 31)
Example 3
State:  [1, 0, 1, 0, 1]
Taps:  [4, 5]
Output:  [1,0,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0,1,1,0,0] and False (since the output has period 21, which is not equal to 2^n - 1)

Is there any leniency regarding the input format? For example, would requiring state input be in the form 10101 rather than [1, 0, 1, 0, 1] be acceptable?

Certainly, the list with square brackets was only a suggested input format.  Spaces and commas should only be used if they are convenient in your language.

May we use 0-indexed taps rather than 1-indexed?

Sure, any unambiguous input format is fine.

GolfScript, 38 characters
:f;:i[{0{(2$=^}f/\+)\.i=!}do;].,)2i,?=

You may declare it as a named function if you enclose the code in {<code>}:F. It takes the top two arguments from the stack and pushes the results back to the stack, e.g. (test it online):
[1 0 1 0 1] [3 5]

:f;:i[{0{(2$=^}f/\+)\.i=!}do;].,)2i,?=

# => yields [1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 0 0 0 1 1 0 1 1] 1

Annotated code:
:f;          # save tap positions (1 indexed) to variable f
:i           # and the initial state to variable i
[{           # the [{...}do;] loop generates an array using the loop
             #   top of stack is the current state
  0          #   push zero (accumulator)
  {          #   {...}f/ loops over all tap positions
    (        #     make the current position zero-indexed
    2$=      #     take the corresponding bit from the current state (2$)
    ^        #     xor with the accumulator
  }f/        #   end of loop
  \+         #   prepend the new bit to the current state
  )\         #   and shift out the last bit (output)
  .i=        #   compare the current state to input
  !          #   if not equal then loop
}do;]        # end of loop - discard the state
.,)          # length of the output + 1
2i,?         # 2^length of initial state
=            # are those two numbers equal?

People have probably used LFSRs longer than that code...

Perl - 78 bytes
sub f{($_,$t)=@_;s//($_&$t)%9&1/e,@o=(@o,chop)until$o{$_}++;@o,$/,@o+1>>y///c}

Input is expected as two binary strings, one representing the current state, and the other the taps. For example, the input ('10101', '00011') corresponds to an initial state with the 1st, 3rd, and 5th bits set (one indexed), with taps on the 4th and 5th bit.
For the truth condition, a 0 or 1 is returned, separated by a newline.
Note: The bit counting logic above, ($_&$t)%9&1, will fail if the total number of bits is more than 16, and/or the number of taps is greater than 8. This can be replaced by ($_&$t)=~y|0||c&1 at the cost of 6 bytes.
Test Case 1
Input:
print f('1010', '0011');

Output:
010111100010011
1

Test Case 2
Input:
print f('10101', '00101');

Output:
1010100001001011001111100011011
1

Test Case 3
Input:
print f('10101', '00011');

Output:
101011111000010001100
0

($_,$t) looks like an emoticon.  Perhaps a mixture of greed and regret.  That gives me an idea...

Javascript (E6) 144 157 169
Edit Output as string instead of array
F=(s,t)=>(P=>{b=s.length,i=s=P(s,2),t=P(t,2);for(o='';!o||i-s;){for(p=q=s&t;q>>=1;p^=q);o+=s&1,s=s>>1|(p&1)<<b-1}})(parseInt)||[!!o[(1<<b)-2],o]

Ungolfed
F=(s,t)=>
( P => { // Inner block, spare a final 'return'
  b = s.length,
  i = s = P(s,2), t=P(t,2);
  for (o='';!o||i-s;) {
    for (p=q=s&t;q>>=1;p^=q);
    o += s & 1,
    s = s >> 1 | (p&1) << b-1
  }
} ) (parseInt)
|| [!!o[(1<<b)-2], o]

Usage
State and Tapped position input as strings of bits (format A)
  Return an array with true/false and a string of output bits
Test
Javascript console in firefox,
F('1010', '0011') [true, "010111100010011"]
F('10101', '00101') [true, "1010100001001011001111100011011"]
F('10101', '00011') [false, "101011111000010001100"]

Go, 208 bytes
import."slices"
func f(S,T[]int)(o[]int,m bool){s:=S
for len(o)<1||!Equal(s,S){l,L:=S[T[0]],len(S)-1
for _,i:=range T[1:]{l^=S[i]}
o,S=append(o,S[L]),append([]int{l},S[:L]...)}
O:=len(o)+1
return o,O&(O-1)<1}

Attempt This Online!


text:
Check If Two or More Variables Are All Equal to Zero in JavaScript
What is the shortest way to check if two or more variables are equal to 0 in JavaScript?
I'm curious to know if there's something shorter than if(!x&&!y&&!z){...}.

This might be better suited for StackOverflow or CodeReview.

If you want the shortest solution in bytes in order to improve golfing down this particular snippet, I think this is well on-topic here (not as a challenge, but as a question asking for golfing advice). If you want the fastest solution, this should rather go in Code Review (and no one prevents you from posting both separately). But the shortest solution will not necessarily be the fastest solution. So what is it you want?

wouldn't !(x|y|z) work?

Questions on this site should either the contests or asking for tips participating in those contests. Do yourself a favor and don't use any code you find on this site in "the real world", unless you understand exactly what it does. Also, in general, you have to decide between the shortest and the fastest solution.

Seeing my answer was apparently what you were looking for, I took the liberty to edit your question to make it more on-topic (and justify my subsequent reopen vote). Feel free to edit the question again if you don't agree with my changes. As stated before, for help with efficiency, try StackOverflow or Code Review.

Code Golf it is... and yes, I know not to use code from this site in production.

If the question doesn't get reopened and more answers posted by tomorrow, I'll re-mark your answer as final. However, if reopened and shorter answers are posted, I'll oblige per the rules of the site.

I don't think code-golf and tips are combinable. In my opinion, this is a tips question, since code golf contests are usually more complex and not restricted to a single language.

@Dennis I'd say in the presence of a tips tag, code-golf loses it's "this is a challenge" meaning but says "this is a question about tips regarding code golf" (as opposed to some other type of code challenge). I feel like this may have been discussed on meta, though.

@m.buettner: Looking at other tips questions, you might be right. My previous comment was mostly directed at the OP, who vowed to oblige per the rules of the site. There are no rules for tips questions.

(EDIT: This first part refers to the original phrasing of the question.)
First, (!x&&!y&&!z) returns a boolean, which makes ?true:false entirely redundant. It's basically like using
if (x == true)
  return true;
else if (x == false)
  return false;

instead of return x;.
That gives you
!x&&!y&&!z

(EDIT: The remainder still applies to the new version of the question.)
Now you could apply De Morgan's law. The above is equivalent to
!(x||y||z)

Which is the same length for 3 variables and longer for 2 variables. But for each variable beyond the third, you save one more character!
Lastly, if you know that your variables are numbers, you can also use the bitwise operator, i.e.
!(x|y|z)

If you actually need booleans (which I assume from your snippet), this doesn't work for the & case, because !x&!y&!z will give you an integer. Then again, in JavaScript it's often enough to have truthy or falsy values, in which case, that's a perfectly valid option.
Bonus tip: if you ever want to turn a truthy/falsy value (like a non-zero/zero number) into a boolean, don't use x?true:false either, but use !!x instead. !x is a boolean with the opposite truthiness/falsiness than x, so !!x is true for x truthy  and false for x falsy.

Very insightful! I appreciate you exploring several possibilities, despite the nature of the question being somewhat vague and potentially misinterpretable.

Just an addendum.
In the special case where the block contains just a procedure call, you can replace
if(!x&&!y&&!z){call();}

by
x||y||z||call();

This idiom is important in other contexts.

This function is obviously not the shortest until you have a lot of numbers to check (the poster did say "or more").
It verifies that all arguments are equal to zero.
function AllZero() {
    var args = Array.prototype.slice.call(arguments);
    args.push(0);
    return Math.min.apply(Math,args) === Math.max.apply(Math,args);
}

If you push a different number in the args.push(x) line, it will check that all of the arguments are equal to that number.

Why would you recommend this instead of a simple loop? Also AllZero('', '', '')


text:
Write a piece of code to output the line number of the print / output statement itself (in the form "Hello World, from line X!")
The Challenge
Write a program that outputs Hello World, from line X!, where X is the line number, in the source code, of the actual print statement itself.
The Rules

In this context, we want the first line number of the statement which outputs the string to be displayed to stdout
You should avoid simply searching through your source code as a string (either file or quine) to find the line number
If any additional whitespace or statements (which do not interrupt the flow of the code) is added to the source code, it should be reflected at run-time (after compiling if applicable)

Recommendations
If provided by the language, you may use exceptions/stack traces to accomplish this goal.  Try your best to use code that is portable across different systems/implementations, but note that this is not a requirement.  Using defined variables like __LINE__, although allowed by the rules,  are discouraged.
The Winner

This is a popularity contest (ended on June 10, 2014), where the answer voted highest by the community will be declared the winner based on the current votes at the time
When voting, please consider the creativity of someone's answer, how elaborate or interesting it is. and the difficulties/constraints of the programming language being used

What do you mean by "the first line number"? Are you talking about what should happen if the statement spans multiple lines?

@user2357112 yes, just to resolve any ambiguity if anyone needed to use a milti-line statement.

The title is very explicit, but perhaps a bit long.

@primo updated, what do you think of the new title?

@Breakthrough I think it's better, because the point of the challenge is listed first (which, when the title is cropped see here, is the only thing that's visible). I might even consider removing the bit in parentheses; how it needs to be done should be detailed in the challenge description.

The answers to this are all boring because it is such a bad question.  It is like the asker didn't know of the existence of LINE.  In fact I signed up specifically to down vote this I thought it was so bad.

@dave that's why this is a popularity contest, and in the scoring criteria, I've asked people to consider how elaborate/interesting someone's solution is relative to the language they used (e.g. this Ruby one-liner).

why shouldn't we just put on one line? e.g. document.write('Hello World, from line 1');

@Markasoftware if a line was added before it, the output wouldn't change to reflect that.

oooooohhhh, I understand now. I didn't understand the grammar in the third point of the rules, now I get it. Thanks!

Sinclair Basic
10 PRINT "Hello world, from line ";PEEK 23621;"!"

Hello world, from line 10!

This will work for any line by PEEKing at the address storing the current line number, so the following will work as well:
341 PRINT "Hello world, from line ";PEEK 23621;"!"

Hello world, from line 341!

And by the same token, Timex/Sinclair BASIC!

I don't pretend to know this language, but can't you leave out the STR$ if you replace the + signs by semicolons?

@MrLister Yes, that would definitely work but I always use +s from habit.

BASIC
I think this does everything that was asked for:
10 PRINT "Hello World, from line 10!"

If any additional whitespace or statements (which do not interrupt the flow of the code) is added to the source code, it should be reflected at run-time (after compiling if applicable). The intent is there. Also, that is the first line of the source, not the 10th.

It may be the first line in the source code, but it's still line 10.

It's a nice idea, so a plus anyway.

Now I've kind of copied it http://codegolf.stackexchange.com/a/30085/16411, only more so :-)

I believe this falls firmly under the no longer funny category. It's really unimaginative and uninteresting, although literally it meets the requirement. Why does this have so many upvotes? (I've downvoted)

I really do like this answer, and it is indeed very interesting - but I have to agree with @TimS.  With respect to the challenge itself, it would be nice if solutions determined the line number programmatically.

This is a great answer because it takes a silly but specific advantage of an aspect of the BASIC language which is not commonly found in other languages (especially modern ones). It may not be the most popular (time will tell), but I can hardly see how it's less interesting than using a constant such as __LINE__ or getting debug info from the current stack frame (as most other answers currently do).

Clever, but I'd be disappointed if nothing else ended up with more upvotes than this one.

@Nick There's nothing great with this answer because the line number is hard-coded. Nothing's dynamic out there. You have to modify the text to display if you need to put more than 10 lines of code before priting the message.

Golfier? 1 PRINT"Hello World, from line 1!"-3

Java
public class Hello{
    public static void main(String[] args) {
        System.out.println("Hello World, from line "+new Exception().getStackTrace()[0].getLineNumber()+"!");
    }
}

I'd prefer Thread.currentThread().getStackTrace()

Thread.getStackTrace() calls (new Exception()).getStackTrace() if called on the current thread, so it's the same thing

weird.... 2x same answer and 2 different upvote amounts... (could be used as RNG source...) (same here: http://codegolf.stackexchange.com/a/30058/10801)

@masterX244 those two answers aren't exactly identical; this one uses the getLineNumber() method on the stack trace, while the answer you linked to uses toString() on it to find the line number.

but still pretty funny how the small difference results in different upvotes... (somehow IDE refused to show linecount method for me in autocomplete)

@masterX244 it's also worth noting that this answer appeared 2 hours earlier. The second time I see an answer, it isn't as interesting as the first.

Perl
close STDERR;
open FOOBAR,">",\$_;

print!warn,'Hello World, from line ',/(\d+)\.$/,'!';

Not quite as short as using __LINE__, but perhaps more interesting.

 warn is a debugging tool, which issues a statement to STDERR, indicating in which file, and on which line the warning was issued... unless STDERR has been previously closed or is otherwise inaccessible, in which case the warning is issued to the most recently opened file handle - this is undocumented behavior. I'm not sure if it would be better classified as a feature or a bug.

 Here, STDERR is closed, and a new file handle identified as FOOBAR is opened, and routed to the variable $_. This is then parsed to retrieve the line number of the warning, which is embedded in the print statement.

Yes, it definitely is more interesting :)

C++
#include <iostream>
#include <utility>
#include <type_traits>

#define __(A,B,C,...) B##C##A
#define _(A,...) __(__VA_ARGS__, A)
template<unsigned...Is> struct v;
template<unsigned I0, unsigned... Is> struct v<I0, Is...>:v<I0-1,I0-1, Is...> {};
template<unsigned...Is> struct v<0,Is...>:std::integral_constant<unsigned, sizeof...(Is)> {};

int main() {
  std::cout << "Hello world from line " << v<_(EXTRACT,_(Q,_,E,_,$$main$$,),_(@22,,_,_),_(Z,N,L,I,_,,L),__STACK_TRACE__)>::value << "\n";
}

live example

This is ... wizardry

It took me a ... long while to see how this worked. Soo many red herrings! It's delicious.

So how does it work?

C
#include <stdio.h>
main(){
printf("Hello World, from line %d!", __LINE__);
}

Using defined variables like LINE, although allowed by the rules, are discouraged.

@vaxquis, yes but my answer predates that edit to the question

it's still a lousy and too obvious solution IMO. I'm wondering why people posted all kinds of variations of this solution in all languages of the world (including PHP, D, Perl) instead of even trying to do something remotely funny or intriguing?

Lua
print("Hello world, from line "..debug.getinfo(1).currentline.."!")

C#
C# 5.0's [CallerLineNumber] does the trick:
using System;
using System.Linq;
using System.Runtime.CompilerServices;
namespace LineNumberConsole
{
    class Program
    {
        public static void Main()
        {
            Console.WriteLine("Hello World, from line {0}!", ToRoman(GetLineNumber()));
            Console.ReadLine();
        }

        private static int GetLineNumber([CallerLineNumber] int sourceLineNumber = 0)
        {
            return sourceLineNumber;
        }

        private static string ToRoman(int number)
        {
            // TODO: Copy some source code from http://pastebin.com/w0hm9n5W
            // Skipped here for brevity
            return number.ToString();
        }
    }
}

Output
Hello World, from line X!

Any particular reason to use roman numerals?

When the printing line is line 10, the question is interpreted literally. X in roman numerals is 10.

Roman numerals is a nice touch!

Python
Example (10 lines, 213 characters):
import sys
import traceback
lineno = None
while True:
    try:
        print 'Hello World, from line %d!' % lineno
        break
    except:
        lineno = traceback.tb_lineno(sys.exc_info()[2])
        continue

Try online here. Non-flow altering code and whitespace can be added and the program will display the updated line count, and likewise, this code snippet can also be used anywhere in an existing program. Expected output:
Hello World, from line 6!

Another example (try online here) to show that it works when code/whitespace is added. Expected output:
Down we go...
Gotta catch 'em all.
Down we go...
Hello World, from line 11!
Awesome!

Javascript
function getLine(n) {
   try {
      to
   } catch (dat) {
      var stack = dat.stack.split('\n');
       for (var i = 0; i < stack.length; i++) {
           if (~stack[i].indexOf ('getLine')) break;
       }
      return dat.stack.split ('\n')[i + ~~n].match (/:(\d+)/)[1] - ~~window.hasOwnProperty ('__commandLineAPI')
   }
}
//Line 12
console.log ('Hello World, from line ' + getLine(1) + ' !')

Note: Expressions, evaluated from within the chrome dev console will be wrapped in a with statement. Thus we need to decrement the line by one if that's the case

dat stack, hehe.  Verified working on Firefox.

@Breakthrough :) Yes it works cross-browser (only tested with the latest Chrome,FF,IE though). Chrome needs special treatment when evaluated from within the console, as it wraps every statement in a with clause.

Interesting but ambiguous username. Monosodium glutamate, perhaps? (BTW, I'm thinking of doing a question on DNA and amino acids, of which glutamic acid is one.)

@steveverrill According to google, you are correct!

@kitcar2000 Probably. But there are other lesser-known compounds with this formula: Sodium methylaspartate or nitropentanoate, for example.

Python 3
import hashlib
with open(__file__) as f:
    line_num = 0
    for line in f.readlines():
        line = line.rstrip() # make it work with or without newline at the end
        line_num += 1
        if hashlib.sha256(bytes(line, "UTF-8")).hexdigest()[0:6] == 'cc46f7':
            print('Hello world, from line {}!'.format(line_num)) # cc46f7

Hello world, from line 8!

This self-reading code contains a self-referencing hash. The SHA256 sum of the last line (with the beginning whitespace and without trailing whitespace) begins with cc46f7.... When it hashes the print line, it finds that the hash matches the magic value it's searching for.

couldn't you just set line_num = to -1 and have the print outside the loop and get ride of the magic hash?

@dave not sure I follow you. The magic hash is what makes this solution clever.

+1 for literal interpretation of my rules :)  Very clever.

A working solution. But it is not even close to something someone might use in practice e.g. within a logging framework to determine the caller's line number.

@Stefan This site is all about worst practices, though. ;)

can you show a live version that works, while having the # cc46f7 comment too o.O That would be impressive. On my box, I had to tweak the line as well as the checksum in order to make it work :(

@sehe Most likely, this was due to whitespace issues. I didn't have a newline at the end of the file when I made it. I've added a line to strip whitespace from the end of the line before hashing. It should work more consistently now. (also make sure you're not converting the spaces to tabs) I tried uploading it to ideone to show you a live version, but it can't read its own file there.

I don't think this works. (untested but) it looks like I can add three layers of if 0: then the relevant statement to throw it off.

GNU COBOL
Well, they said it couldn't be done. Actually, it was I who said it couldn't be done. Now it's done, and an obsolete language feature re-implemented using the method applied.
The question states:

If any additional whitespace or statements (which do not interrupt the
  flow of the code) is added to the source code, it should be reflected
  at run-time (after compiling if applicable).

Any amount of stuff can be inserted prior to the three DISPLAYs which cause the start of the output, and anything after the DISPLAYs would "interrupt the flow of the code", so that's OK.
COBOL used to have a TRACE verb (statement) which simply listed source line-numbers as they were executed (no access to the line number in the program). Although of limited use, I've included an implementation of TRACE.
   ID Division.
   Program-ID. HIWHERE.
   ENVIRONMENT DIVISION.
   configuration section.
          source-computer. TinkerToy with debugging mode.
   Procedure Division.
   Declaratives.
   Debug-Declaratives Section.
       Use For Debugging on a b
       .
   Debug-Declaratives-Paragraph.
       Display Debug-Line "!"
       .
   End Declaratives
       .
   Main-Program Section.
       DISPLAY "Perform"
       Display "Hello World, from line " no advancing Perform b
       display "GO TO"
       Display "Hello World, from line " no advancing GO TO a
       .
   a.
       dISPLay "Fall through"
       Display "Hello World, from line " no advancing. b.
   The-Last-bit-OF-the-PROGRAM.
       GOBACK
       .

The output is
Perform
Hello World, from line     18!
GO TO
Hello World, from line     20!
Fall through
Hello World, from line     23!

As an exhibition of the power and flexibility of writing the language, this example uses mixed-case, entirely lowercase, and entirely uppercase, all at the same time. It does not matter, as when processed, everything is "folded" to UPPERCASE.
The only standard COBOL way to get at a source line-number in the running program, from the running program, is with a DEBUGGING DECLARATIVE. Within a SECTION, strictly within a paragraph within a SECTION, of a such a declarative you have access to the special-register DEBUG-LINE. This contains the source line-number of the verb (statement) which caused transfer of control to a particular procedure-name (paragraph or SECTION).
So, with PERFORM, or GO TO, or "fall through" the paragraph in the debugging declaratives SECTION is executed.
OK, but DISPLAY does not cause transfer of control.
No problem. Put it on the same line as the transfer of control.
Problem, since if "any additional whitespace or statements (which do not interrupt the flow of the code) is added to the source code, it should be reflected at run-time (after compiling if applicable)".
So, put it on the same line but in front of a transfer of control, split the content of the DISPLAY into two pieces (remember, "In this context, we want the first line number of the statement which outputs the string to be displayed") and output the first part prior to the transfer of control, and the second part, from the DEBUG-LINE, once inside the debugging procedure.
The final tricky bit is for the "fall through" ("procedures" can be PERFORMed, can be the target of a GO TO, or can be entered simply by being the next line along). In this instance, put the DISPLAY on the line which defines the procedure, but in front of the definition.
The names of the "procedures" (a and b) have been severely shortened to allow them to fit on the same source-line as the DISPLAY. Strictly a COBOL procedure-name should start somewhere from column eight to column 11. However, the syntax is, these days, much more relaxed about that. To the extent that I can define a procedure name on the same line as some code. Even embedded in code. Care, and an occasional full-stop, is required.
In the PROCEDURE DIVISION each full-stop shown is required, and no more are.
To compile:
cobc -x -g hiwhere.cbl

To execute (linux):
COB_SET_DEBUG=Y ./hiwhere

Finally, the return of TRACE (without READY/RESET).
   ID Division.
   Program-ID. tRacE.
   ENVIRONMENT DIVISION.
   configuration section.
          source-computer. TinkerToy with debugging mode.
   Procedure Division.
   Declaratives.
   Debug-Declaratives Section.
       Use For Debugging on a
       .
   Debug-Declaratives-Paragraph.
       Display Debug-Line
       .
   End Declaratives
       .
   Main-Program Section.
  *    Just append "perform a" to a single-line statement.
       DISPLAY "1" . perform a
       Display "2" . perform a
       display "3" . perform a
  *    Or prepend "perform a." for a multi-line statement, or a
  *    statement which won't "come back".
       perform a. GOBACK
       .
   a.
       CONTINUE
       .

Output is:
1
    17
2
    18
3
    19
    20

Where 1, 2 and 3 are output from the three DISPLAY statements, and 17, 18, 19 and 20 are the line numbers of the "executable" (non-debugging) lines.

Java
Using the behavior of Exception's stack trace to get current line. as long as Printstatement isn't mangled into multiple lines or classfile gets mangled it should work
public class PrittLnbr
{
    public static void main(String[] args)
    {
        System.out.println("Hello World, from line "+new Error().getStackTrace()[0].toString().split(":")[1]+"!");
    }
}

Python
import traceback, inspect
frame = inspect.currentframe()
print("Hello World, from line "+traceback.format_stack(frame)[0].split()[3][:-1]+"!")

Befunge
Done just for fun.
>00g1+:00p"v"\10v
    v-*45g00p\g <
#v+1_$10g1vv,,,,<
^<p000p01+<#>,,,^
>" enil morf ,oll"v
@.,,,,,,,,,<^,"He"<

Conditional: top left of the code has to be 0 < x < 20 and 0 <= y < 62; and the two first cells have to be empty.
example:
                         v

                         0
                         0
                         0
                         p
                         0
                         1
                         0
                         p
                         >00g1+:00p"v"\10v
                             v-*45g00p\g <
                         #v+1_$10g1vv,,,,<
                         ^<p000p01+<#>,,,^
                         >" enil morf ,oll"v
                         @.,,,,,,,,,<^,"He"<

Would output:
Hello, from line 10

No idea what this was, but I believe your output claim, so +1 ;-)

For those who question the power of mighty Befunge, try it out here: http://www.quirkster.com/iano/js/befunge.html

Perl
print 'Hello World, from line '.__LINE__.'!';

This is also a valid PHP solution.

Java
public class HelloFrom {
    public static void main(String[] args) {
        System.out.println("Hello World, from line " + Thread.currentThread().getStackTrace()[1].getLineNumber() + "!");
    }
}

technically the same as i did (http://codegolf.stackexchange.com/a/30058/10801)

Sort of, except using the current Thread instead of creating a new Error to get the stack trace. There isn't any error ;)

Python
import inspect
print ("Hello world from line %d!" % (inspect.getlineno(inspect.currentframe())))

Output
Hello World from line 2!

Best Python one so far!

C
By using a variadic macro, we can make a print function which automatically adds the line number to the end of an arbitrary printf statement, and always prints to stdout.
test.c:
#include <stdio.h>

#define printfl(format, ...) fprintf(stdout, format " From line %d\n", ##__VA_ARGS__, __LINE__)

int main() {
    printfl("Hello World! I have %d argument(s).", 1);
    return 0;
}

outputs:
% ./test
Hello World! I have 1 argument(s). From line 6

Note: I deviated from the pattern to demonstrate that printfl is still a valid variadic function; if you really care about the format of the output, you can always change the literals I use.

This only works if you use a constant format string. It fails if you pass in any other expression for the format string.

Bash
#
# some comments to fill some lines...
#
echo "Hello World, from line $LINENO!"

Output
Hello World, from line 4!

@professorfish ... what's wrong with MY style to show MY answer? You should at least explain why you manipulate my artwork... :-P

did I change the code? if I did, I'm sorry. I was just worried that non-bash users wouldn't be able to tell what was the source code and what was the output

And evryone else besides me loves seeing his stuff being changed without commenting why? Strange place...

It was basically a formatting fix. There's nothing really wrong with those AFAIK

Using defined variables like LINE, although allowed by the rules, are discouraged.

@vaxquis: OMG!!! :-P

@yeti yup. I hate unsurprising (read: boring) CG solutions, but hell, who am I to judge...

@vaxquis: The sentence about LINE probably was not part of the question (and rules) in the beginning or when I started to think about this. You can check the history of the question by clicking "edit" there.

a) it is now, b) it doesn't change anything regarding the fact that this CG entry is nondescript as far as they go...

(a) I get a notice/hint for every comment or vote but not when someone changes the question text or rules and after all: Who knows how long it will be there? It might vanish tomorrow. :P (b) I do not accept rule changes after I have answered. (c) The statement about LINE variables is not part of the rules. (d) I will not reply on further comments regarding this LINE variable topic. (e) Vote for deleting my answer if you cannot live with this.

D
void main ()
{
    import std.stdio;
    writefln("Hello World, from line %d", __LINE__);
}

Using defined variables like LINE, although allowed by the rules, are discouraged.

C or C++, and AWK
lineno.c:
// code or comments
// ....
#error Hello World, from line
// other code or comments

Usage:
gcc lineno.c 2>&1 | awk '{ split($0,a,":"); ; printf("%s %s!\n", gensub(".*#error ","",1), a[2]); exit; }'

Output:
Hello, World, from line 3
Notes:

No user written code searches the file.
g++ will work on a c++ file.

Kind of boring in Ruby:
puts "Hello World, from line #{__LINE__}!"

This isn't cheating, right?

Nope, this isn't cheating!  This challenge will obviously be a lot easier in some languages and more difficult in others, however, which was why I posted it :)  (I see now why the inclusion of a scoring criteria is so important)

Using defined variables like LINE, although allowed by the rules, are discouraged.

@vaxquis Yeah, that statement was added after this answer.

Javascript
One line using stack trace.
(function (o) { console.log("Hello World, from line " + (Error.captureStackTrace(o) || o.stack.match(/\d+/)[0] - !!__commandLineAPI) + "!"); })({});

Ruby
File.write "hello.rb", "x=2\n"+"x+=1\n"*rand(rand(100))+'puts "Hello World, from line #{x}!"'
system "ruby hello.rb"
File.delete "hello.rb"

Cobra
class Program
    def main
        print 'Hello World, from line [System.Diagnostics.StackFrame(true).getFileLineNumber]!'

Python
import traceback

print 'Hello World, from line %i!' % traceback.extract_stack()[0][1]

Short and sweet.

Powershell
$l=(Get-PSCallStack | ForEach{$_.Location})[0].split(' ')[-1]; "Hello World, from line $l!"

And:
try{ I AM ERROR. } catch { $l=$error[0].InvocationInfo.ScriptLineNumber; "Hello World, from line $l!" }

Both work like this:
PS C:\MyFolder> .\helloworld.ps1
Hello World, from line 1!

+1, but Write-Host doesn't write to stdout. Simply passing the string will send it to stdout. E.g. "Hello World, from line {0}!" -f (gcs| %{$_.ScriptLineNumber})[0]

@Rynant Good point! I'll update my answers to consider that...

PowerShell
Cheap Move
Function LemmeGetDatError() {
    "Too busy chuggin along"
    "Then all of a sudden, I meet a new programmer"
    "And he's all like"
    Write-Output "$(Try {"Hello World from"; Throw "error" } Catch {$_.ScriptStackTrace.Split(":")[1]})"
}

LemmeGetDatError

Perl
Another Perl one:
use warnings;

$SIG{__WARN__} = sub { ($line = shift) =~ s/\D//g; };

$x=$x+1; print "Hello World, form line $line!\n";

Inspired by @squeamish ossifrage's answer with BASIC.
What's in a line number?
In, for instance, IBM COBOL there are (can be) arguably three source line numbers.
The first (if used, it is optional), in columns 1-6 of the punched-card, are sequence numbers for the card deck. If the deck is dropped, the otherwise-hapless programmer has some chance to get things back in order. OK, starts to go slightly floppy as soon as the program has lines added, but that's what different coloured cards are (can be) for.
The second is on the compiler listing, generated by the compiler. The compiler diagnostic messages use this line number, else no-one would have much of a clue (unless the diagnostics are embedded, which they can be) which line any particular diagnostic referred to*. These numbers for various reason (copybook code, let alone anything else) will be different from the first.
The third line number is of course the line number of the actual source file (optional, columns 73-80 if present). Other than actually reading the source file, or hard-coding a reference to a particular source line-number, it would not be possible to get this number in a program***.
So:
999999     DISPLAY "Hello, world, from line 999999!"

This can appear anywhere in the PROCEDURE DIVISION of the program, since those line numbers have no affect on the program, and are only even flagged as out of sequence (not ascending, can be gaps) if requested by compiler option.
** With compiler options SEQUENCE and NUMBER, the column 1-6 numbers will be used (modified by the compiler if necessary) for the diagnostic messages, and other data requiring source line numbers.
* OK, possible in limited circumstances. No copybooks. Then you get the editor to put the sequence numbers of the source program (yes, we have actual sequence numbers, not just counting the lines) in columns one to six, and use compiler options SEQUENCE and NUMBER and then have a DEBUG DECLARATIVE, have the DISPLAY on the same physical line as the paragraph/SECTION which is going to cause the DEBUG DECLARATIVE to execute.

Nimrod
template lineno(): expr = instantiationInfo().line
echo "Hello, world, from line ", lineno(), "!"

It uses Nimrod's templates to generate a call to instantiationInfo, whose information is only valid when used from within a template.
Output:
Hello, world, from line 2!

C#
using System;
using System.Runtime.CompilerServices;
namespace LineNumber
{
    class Program
    {
        int getLn([CallerLineNumber] int x){ return x; }
        public static void Main()
        {
            Console.WriteLine ("Hello World, from line " + getLn() + "!");
        }
    }
}

There is more than one way to do it (Perl 5)
The boring way:
print "Hello World, from line ", __LINE__, "!\n";

A fancier way:
sub println { print @_, ", from line ", (caller)[2], "!\n" }

println "Hello World";

A sneaky way:
eval {
    die "Hello World";
};

print $@ =~ s/ at .* (line \d+)\./, from $1!/r;

An even sneakier way:
$SIG{__DIE__} = sub { exit print $_[0] =~ s/ at .* (line \d+)\./, from $1!/r };

die "Hello World";

The really sneaky way:
package Magic {
    use Filter::Simple sub { s/42/\${\\__LINE__}/g };
}
BEGIN { import Magic }

print "Hello World, from line 42!\n";

PHP
Shamelessly stolen from gnibbler
<?php
printf("Hello World, from line %d!", __LINE__);

Working example

ECMAScript (JavaScript):
alert('Hello World, from line ' + Error().lineNumber + '!');

Hello World, from line 1!

Note: I've only tested this in Firefox and Opera 10.

This should work in all current browsers:
alert('Hello World, from line ' + /^.*?@.+?:(\d+)(:\d+)?\r?\n/.exec(Error().stack)[1] + '!');

Hello World, from line 1!

Befunge 98
This code snippet assumes that the IP comes downward into the upper left n. Otherwise, it fails.
n
>v>" enil morf ,dlroW olleH"bb+k,.@
^>:'^\1\p1+
 ][

The n (and newline) can be removed if I can assume that the stack is empty when it enters this snippet.
There is one discrepancy between this output and the one requested: instead of a ! at the end of the printed statement, this outputs a space because Befunge automatically appends a space to numbers that are outputted. I could easily add a ! after that. Fixing this would require a mess of ugly code.
You may add extra newlines anywhere and the code will still work. Spaces are more restricted, but may be added in several places. For instance, they cannot be added as the first character in any line.
Sample program:
v

n
>v>" enil morf ,dlroW olleH"bb+k,.@
^>:'^\1\p1+
 ][

Output:
Hello World, from line 12

x86 Assembly
.data
LC0:
    .ascii "hello, world! from address %x\n\0"
.text
    .global main
main:
    pushl   %ebp
    movl    %esp, %ebp
    call pop

pop:
    popl    %ebx
    leal    22(,%ebx,1), %ebx
    subl    $8, %esp
    movl    %ebx, 4(%esp)
    movl    $LC0, (%esp)
    call    printf
    movl    $0, %eax
    leave
    ret

This prints the memory address where the call to printf is located. This doesn't really work for rule 3, but I feel it's much more interesting than using __LINE__ or a stacktrace.
I should add how it works. Normally you can't get the address of the current instruction pointer by moving it into a register, so what I do is call a function "pop" which really means that the return address of the next instruction is pushed onto the stack and then a jump is executed. I pop this return address into ebx and add 22 to get the address of the printf call. The reason this won't work for rule 3 is that if you insert code before the printf call the address will not be 22 away from the address of the pop ebx.

POSIX SHELL:
I was going to do $LINENO but it's been done. So I'll ask an interactive POSIX-compatible shell to printout its current history line number instead:
HISTFILE= PS1='${hi}$(printf "${hi:+\!!!\n}> ")' sh -i
> hi=${on='Hello World, from line '}${off=}
Hello World, from line 2!
> hi=$off
> hi=$on
Hello World, from line 4!
>

Though it may not look like it, the shell is actually reevaluating and printing anew that $PS1 variable for every command it receives - else it wouldn't even work - so the print statement actually is printing its own line number every time it prints and not just the first.

Haskell
{-# LANGUAGE CPP #-}
main = putStrLn $ "Hello World, from line " ++ show __LINE__ ++ "!"

Hello World, from line 2!

PHP
echo "Hello world, from line " . __LINE__ . "!";

Batch Script
@echo off
set /a %line%==10
echo Hello world at %line%
pause
exit

Can you please explain how "Hello world at 10" points to the 3rd line in the script? Or, maybe there's some non-obvious batch syntax behind this?

JAVASCRIPT - NON-Standard
console.log('Hello World, from line %d!', (new Error).lineNumber);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber

Python 2.7
# Any number of whitespace, code, etc.

# In this case, when greet() is called, it will output "Hello world, from line 4!"
def greet():print "Hello world, from line " + str(greet.func_code.co_firstlineno) + "!"

Originally I wanted to implement an overkill compiled code parser, but gave up, this is still a good one tho.