+ 27

{Important} This thread is for weird & interesting programs! {Check it}

Friends these are the program that i thought interesting if you know some you can post yours. In C/C++ you can have as many semicolons as you want at least in the MS C++: int main(void) { cout<<"Hello World";;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; return 0;;;;;;;;;;;;;;;;;;;;;;; } POST if you have one and explain these if you like.

4th Mar 2017, 5:25 PM
Ram chandra Giri
Ram chandra Giri - avatar
20 Respuestas
+ 25
In JavaScript: alert(111111111111111111111) // alerts 111111111111111110000
4th Mar 2017, 5:24 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 24
In java: int x = 1 + + + + + + + + + + + + + 1; System.out.println(x); Outputs 2.
4th Mar 2017, 5:23 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 22
In PHP one can do: System.out.print("hello");
4th Mar 2017, 5:24 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 17
In Python: from __future__ import braces #Output: SyntaxError: not a chance
4th Mar 2017, 6:47 PM
Jafca
Jafca - avatar
+ 17
try this in java: try { throw new AssertionError(); } finally { return false; }
5th Mar 2017, 3:55 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 17
For java: Integer.valueOf(127) == Integer.valueOf(127); // true, same instance Integer.valueOf(128) == Integer.valueOf(128); // false, two different instances
5th Mar 2017, 3:56 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 17
In C#, this doesn't generate a compiler warning: public int Something { get { return Something; } set { Something = value; } } When called, it causes your app to crash, it's a StackOverflowException.
5th Mar 2017, 3:57 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 16
The following text is a single complete comment:(java) /* this comment /* // /** ends here: */
5th Mar 2017, 4:04 PM
Ram chandra Giri
Ram chandra Giri - avatar
+ 15
In C#, you can also have as many ; as you want
4th Mar 2017, 6:44 PM
Jafca
Jafca - avatar
+ 7
My favorite in Python is: import this
4th Mar 2017, 7:22 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
What's interesting about this is that Python lets you override keywords. It was a typo (equals is adjacent to backspace) that I helped someone fix, which breaks the interpreter (easiest fix is reload): aTuple=(1,2) print=("take that"+"and that") print(aTuple) Error: 'str' object is not callable. (on the tuple print)
5th Mar 2017, 12:32 AM
Kirk Schafer
Kirk Schafer - avatar
+ 6
In python,try this: d = {True:"Sun"} d[1] = "Moon" print(d)
4th Mar 2017, 6:45 PM
Riman Das
Riman Das - avatar
+ 6
in c++ you must know to swap you can do a=a+b-(b=a);;;; you must also know that a+=b+z-x; is evaluated to a=a+b+z-x; but a=a+b-(b=a); and a+=b-(b=a); don't yield same result.
4th Mar 2017, 6:51 PM
Megatron
Megatron - avatar
+ 5
Have you found something like these in python?
4th Mar 2017, 5:37 PM
Riman Das
Riman Das - avatar
+ 5
In python: print("""""text""""") outputs: ""text
4th Mar 2017, 5:59 PM
Riman Das
Riman Das - avatar
+ 5
for (int i=0; i<5; i++, extraAction()) { // c, c++ }
5th Mar 2017, 5:57 PM
Kirk Schafer
Kirk Schafer - avatar
+ 5
Duff's Device. Sometimes considered skiddish, intended to save condition cycles, sometimes faster than a standard 'for' loop (but worse if ported badly): https://code.sololearn.com/cT46etCvzTbO/?ref=app Notice how 'case' jumps into the middle of the do..while; it sends 2 values, then loops and sends the next 8. One loop vs 10. Final byte is printed to prove it finishes. Output is assumed to be a memory-mapped stream (so something would be watching the output byte change; this sample just couts the last value).
6th Mar 2017, 5:42 PM
Kirk Schafer
Kirk Schafer - avatar
+ 3
oh, cool. In python : Swap the value of 2 variables a,b = b,a
9th Mar 2017, 10:45 AM
Stark
Stark - avatar
+ 2
In C++ : You can override the operator ','
5th Mar 2017, 7:41 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar