text:
Generate a random sequence of numbers
The challenge:

Generate a random sequence of numbers. The only input should be the length of the sequence.
Extra internet points for pure-functional solutions.

Note: This is a code-trolling question. Please do not take the question and/or answers seriously. More information here.

http://xkcd.com/221/

http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/00000/2000/300/2318/2318.strip.gif

Code-trolling is in the process of being removed, as per the official stance. This question has many answers and votes, recieved exactly 50% "keep" votes on the poll, and is one of the first [code-trolling] posts, so I am locking it for historical significance.

Python
Grab a random wikipedia article, and take a sequence of html characters of length num, and get their numerical values
import urllib2
from random import randint
def getRandom(num):
    response = urllib2.urlopen('http://en.wikipedia.org/wiki/Special:Random')
    html = response.read()
    html = html.replace(" ", "")
    htmllen = len(html)
    #I especially love how I still grab a random number here
    l =  randint(0, htmllen - num)
    data = html[l:l+num]
    return [ ord(x) for x in list(data) ]

print getRandom(25)

I liked my answer... but I NEED to +1 this.

And the moral of the story is: Using Wikipedia for your homework is cheating.

The only part that I don't like is that probability distribution for different numbers isn't uniform. But that is easily forgiven, because this is awesome.

@Kevin: The OP did not require uniformly distributed random numbers. In fact, this gives me an idea …

All the programs from the other answers will only generate so-called “pseudo-random numbers”, which may look random to the untrained eye but actually follow some pattern.
The following program generates actual random numbers by turning your computer into a particle detector for background radiation. Since this is based on quantum effects, it’s really random and impossible to predict. And for a bonus, the program actually runs faster, if you launch your computer into space. And yes, that is every bit as cool as it sounds.
C
#include<stdio.h>

int main(void)
{
    int i,j,k,l,m;
    printf("How many random numbers do you want?");
    scanf ("%i",&m);

    for (i=0; i<m; i++)
    {
        j = k = 42;
        l = 0;
        while (j==k)
            l++;
        printf("%i\n", l);
    }
}

Spoiler:
This program generates two identical pieces of memory and then waits how long it takes for background radiation to change one of them. The waiting time is then returned as a random number, which would be exponentially distributed, if it weren’t for integer overflows. Such events being more likely in space is an actual problem in astronautics, which is addressed by radiation hardening. So, every statement in the introduction is true to some extent, apart from the bit about coolness.
Unfortunately, such an event crashing the computer or at least the program is more likely than it affecting exactly those two chunks of memory. Also, it may take a while … Finally, as pointed out by kinokijuf, background radiation is an external process, so j and k should be marked as volatile to the compiler (or you should use a compiler that does not optimise at all).
PS:
Expanding on the idea, one could also just create an array filled with zeros and then print it. There is a chance of ε that background radiation changes the zeros between storing and printing and thus what is printed is random – the OP never said how the random numbers were to be distributed.

+1 Extra points for useless but true.

Note that the background-radiation-detecting code will be optimised out by the compiler.

@kinokijuf: What a shame (does this hold for every compiler independent of the options?). Anyway, since this is code-trolling, I hereby declare this a feature of the answer.

An optimising compiler will first optimise the loop to a while(true), and then remove the unused i and j variables completely.

Unless you mark them as volatile, then your code will in fact work as expected.

Is there some way to ensure that j and k always use certain locations in memory? (I haven't used C much; I'm a Java and C# programmer.) If so, you could design the hardware so that those locations aren't protected by radiation hardening, but the rest of the system is.

@Kevin: The only way I can think of to achieve this is to make this program into an operating system that does nothing else. Anyway, why would you want to do this? Hardware random-number generators exist after all.

This remembers me of a crazy eclipse crash that I got in 2007 because the class java.lafg.String did not exist.

Randomness is hard to achieve on a computer, as they are purely deterministic. Generating random numbers on computers is a very active area of research, often involving state-level actors (See Dual_EC_DRBG). However, on a modern multi-tasking operating system, the thread scheduler may do a passable job in some situations. To do this, we yield control of our current time slice back to the operating system, and make note of how long it takes for us to be scheduled again. Depending on the operating system and the load, this may produce the desired results.
const int bitsInInt = 31;

void Main()
{
    Console.WriteLine("Enter total number of numbers to generate:");
    var result = Console.ReadLine();

    var total = int.Parse(result);
    foreach(var i in RandomSequence().Take(total))
    {
        Console.WriteLine(i);
    }
}

//Generates a random sequence of bits
IEnumerable<int> RandomBit()
{
    while(true)
    {
        var sw = new Stopwatch();

        sw.Start();
        Thread.Sleep(bitsInInt);
        sw.Stop();

        yield return (int)(sw.ElapsedTicks & 0x1L);
    }
}

//Performs the computation for mapping between the random
//sequence of bits coming out of RandomBit() and what
//is required by the program
IEnumerable<int> RandomSequence()
{
    while(true)
    {
        yield return RandomBit().Take(bitsInInt).Reverse().Select((b,i)=> b<<i).Sum();
    }
}

This is almost a serious solution!

C#
As the users of out software are inherently random by their nature, why not use that to our advantage?
This code takes a screenshot, and uses that with some other data to produce random sequence. Bonus internet points for not using built-in Random generator?
public unsafe uint[] GetThemRandom(int length)
    {
        var bounds = Screen.GetBounds(Point.Empty);
        using (var screenshot = new Bitmap(bounds.Width, bounds.Height))
        using (var graphics = Graphics.FromImage(screenshot))
        {
            // can't hurt
            var sZ = (uint)Cursor.Position.X;
            var sW = (uint)Cursor.Position.Y;

            // take the screenshot as the previous experience has though us that the users
            // are sufficiently random
            graphics.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
            screenshot.Save(DateTime.Now.Ticks + ".jpg", ImageFormat.Jpeg);

            var bytesPerPixel = Image.GetPixelFormatSize(screenshot.PixelFormat) / 8;
            var bits = screenshot.LockBits(bounds, ImageLockMode.ReadOnly, screenshot.PixelFormat);

            var scanData = (byte*)bits.Scan0.ToPointer();
            var scanLimit = bounds.Width * bounds.Height;

            // squash the pixels into two variables
            for (var i = 0; i < scanLimit; i += 2)
            {
                var pX = scanData + i * (bytesPerPixel);
                var pY = scanData + (i + 1) * (bytesPerPixel);

                for (var j = 0; j < bytesPerPixel; j++)
                {
                    sZ ^= *(pX + j);
                    sW ^= *(pY + j);
                }
            }

            // generate the numbers
            var randoms = new uint[length];
            for (var i = 0; i < length; i++)
            {
                // CodeProject 25172
                sZ = 36969 * (sZ & 65535) + (sZ >> 16);
                sW = 18000 * (sW & 65535) + (sW >> 16);

                randoms[i] = (sZ << 16) + sW;
            }

            return randoms;
        }
    }

Ruby
The question asks for a SEQUENCE. Here we go again...
$seed = $$.to_i
def getRandom(seed)
        a = Class.new
        b = a.new
        $seed = a.object_id.to_i + seed - $seed
        $seed
end

def getRandomSequence(num)
        molly = Array.new
        0.upto(num) do |x| molly[x] = x*getRandom(x) - getRandom(0-x) end
        molly
end

This is 100% random. No really.
Too bad this code means NOTHING to the OP (what the hell is object_id?)
Also, it's implementation specific, meaning it works or doesn't between different ruby versions (ran this on 2.1.0p0).
On top of that, this can potentially do something really nasty, since OP might experiment with object_id...
Example output:
-2224
12887226055
25774454222
38661682243
51548910124
64436137991

Edit:
modified to use $$ for true randomness (on the OS level).

I could do this in C and get even MORE garbage, but what's the fun in doing pseudorandoms in C?

Python
It is easy to stumble over the common pitfalls: a non-evenly distributed source of random numbers and no randomisation. My solution superbly avoids these issues by using deep mathematical insights and a simple, but effective trick, randomisation with the current time:
from math import pi # The digits of pi are completely randomly distributed. A great source of reliable randomness.
random_numbers = str(pi)
random_numbers = random_numbers[2:] # Don't return the dot accidentally

import time
index = time.localtime()[8] # Avoid the obvious mistake not to randomise the random number source by using localtime as seed.
random_numbers = random_numbers[index:]

number = int(input("How many random numbers would like?"))
for random in random_numbers[:number]: # Python strings are super efficient iterators! Hidden feature!
    print(random)

Works great when tested once for a small set of numbers (9 or less), but severely flawed wen tested little more:

math.pi only contains a few digits after the period
time.localtime()[8] doesn't return the milliseconds or kernel clock, but 0 or 1 depending on whether it's daylight saving time or not. So the random seed changes once every half year by one place. So, basically, no randomisation.
This only returns random numbers between 0 and 9.
random_numbers[:number] silently fails when you enter a number bigger than 15 and only spits out 15 random numbers.

Sadly, this is inspired by the Delphi 1.0 random function, which used to work similarly.

Java
Beware, this is a trick question .....
Most people in Java will use math.random() to help to generate this sequence, but they will get confused because they will only get positive results! random() returns a decimal value from 0 to 1 (excluding 1 itself). So, you have to play some tricks to make sure you get a good distribution of random values from over the entire integer range (positive and negative).
Also, you cannot simply multiply Math.random() and Integer.MAX_VALUE because you this will never include Integer.MAX_VALUE itself as part of the result! Also, it would be logical to do math.rand() * (Integer.MAX_VALUE + 1) so that you get a full distribution, but, of course, this does not work because Integer.MAX_VALUE + 1 will overflow, and become Integer.MIN_VALUE! So, unfortunately, the best solution is to resort to bit-wise manipulation of the data...
So, here is a complete sequence for generating 'n' random values in the range Integer.MIN_VALUE to Integer.MAX_VALUE (Inclusive of both extremes (which is the hard part)!!!!):
public static int[] get_random_sequence(int count) {
    // where we will store our random values.
    int[] ret = new int[count];

    for (int i = 0; i < count; i++) {
        // get a random double value:
        double rand = Math.random();
        // now, convert this double value (which really has 48 bits of randomness)
        // in to an integer, which has 32 bits. Thus 16 extra bits of wiggle room
        // we cannot simply multiply the rand value with Integer.MAX_VALUE
        // because we will never actually get Integer.MAX_VALUE
        //    (since the rand will never exactly == 1.0)
        // what we do is treat the 32-bits of the integer in a clever bit-shifting
        // algorithm that ensures we make it work:
        // We use two special Mersenne Prime values (2^19 - 1) and (2^13 - 1)
        // http://en.wikipedia.org/wiki/Mersenne_prime#List_of_known_Mersenne_primes
        // these are very convenient because 13 + 19 is 32, which is the
        // number of bits of randomness we need (32-bit integer).
        // Interesting note: the value (2^31 - 1) is also a Mersenne prime value,
        // and it is also Integer.MAX_VALUE. Also, it is a double marsenne prime
        // since 31 is also a marsenne prime... (2^(2^5 - 1) - 1). Math is Cool!!!
        //    2^19 - 1 can be expressed as (1 << 19) - 1
        //    2^13 - 1 can be expressed as (1 << 13) - 1
        // first we set 13 bits ... multiply a 13-bit prime by the random number.
        ret[i]  = (int)(rand * (1 << 13) - 1);
        // now shift those 13 random bits 19 bits left:
        ret[i] <<= 19;
        // now add in the 19 random bits:
        ret[i] ^= (int)(rand * (1 << 19) - 1);
    }
    return ret;
}

This produces output like:
[-368095066, -1128405482, 1537924507, -1864071334, -130039258, 2020328364, -2028717867, 1796954379, 276857934, -1378521391]

Of course, the above is a complete BS answer. It does not produce a good description, and it 'hides' a severe bug ( ^= should be |=). it also hides a less-severe bug (the order-pf-precedence means we do not actually multiply by a prime value at all!) Using fancy words, prime numbers, and lots of comments is no reason to trust the code.... Of course, if you want to do the above, you should just use java.util.Random.nextInt()

Java
Now that I look back on the program, I forgot to close the Scanner...
import java.util.Scanner;

public class RandomNumberGenerator
{
    public static void main(String... args)
    {
        String rand = "14816275093721068743516894531"; // key-bashing is random
        Scanner reader = new Scanner(System.in);
        System.out.println("Enter length of random number: ");
        System.out.println(rand.substring(0, Integer.parseInt(reader.nextLine())));
    }
}

(non-troll) You can handle closing streams/etc. much more easily in Java 7 with try (Scanner reader = new Scanner(System.in)) { ... }.

Here's a random number generator, base 2^CHAR_BIT.
char* random(size_t length) {
    char* ret = malloc((length+1) * sizeof(char));
    ret[length] = 0;
    return ret;
}

You should allocate length only. Corrupted data when the example works just fine are the best.

Perl
$\=$$;for(1..<>){$\=$\*65539;$\%=2**31;$\.=',';print""}

I'm doing the same $\ tactic for output as in a different code-trolling answer.  Also, you many notice that I am investing a considerable amount of $$ into the RANDU algorithm.
Edit: To explain better, RANDU is a horribly insecure PRNG.  Wikipedia describes is as "one of the most ill-conceived random number generators ever designed."  It's primary weakness is below:
f(x) = 6*f(x-1) - 9*f(x-2)

In javascript, with a functional style:
var randomSequence = "[5, 18, 4, 7, 21, 44, 33, 67, 102, 44, 678, -5, -3, -65, 44, 12, 31]";

alert("The random sequence is " + (function (sequenceSize) {
    return randomSequence.substring(0, sequenceSize);
})(prompt("Type the size of the random sequence")) + ".");

I wasn't aware that it was possible to write JS like this 0_0

C
This function works very well for small applications for creating random numbers between 0 and 1337. Calling it more than once is advisable to insure maximum randomness.
int* getRandom(int length)
{
    //create an array of ints
    int* nums = malloc(sizeof(int) * length);

    //fill it in with different, "random" numbers
    while(length--)                                //9001 is a good seed
        nums[length-1] = (int)malloc(9001) % 1337; //1337 is used to make it more random
    return nums;
}

My RAM and page files are weeping.

The famous Blum Blum Shub generator. Because random number generators should cryptographically secure, and what better way to provide security than through obscurity.
#include <stdio.h>

long long Blum,BLum,Shub;

#define RAND_MAX 65536
//These two constant must be prime, see wikipedia.
#define BLUM 11
#define SHUB 19

int seed(int);
int(*rand)(int)=seed; //rand must be seeded first
int blumblumshub(int shub){
  //generate bbs bits until we have enough
  BLum  = 0;
  while (shub){
     Blum=(Blum*Blum)%Shub;
     BLum=(BLum<<1)|(Blum&1);
     shub>>=1;
  }
  return BLum>>1;
}

int seed(int n){
  Blum=n,BLum=BLUM;
  Shub=SHUB*BLum;
  rand=blumblumshub;
  return rand(n);
}

//Always include a test harness.
int main(int argv, char* argc[]){
  int i;
  for (i=0;i<10;i++){
     printf("%d\n",rand(97));
  }
}

(Includes terrible variable names, an incorrect implementation based on a quick scan of wikipedia, and useless function pointer magic thrown in for fun)

int argv, char* argc[] Oh god, why?

TI-Basic 83 + 84
:so;first&Input\something And;then:Disp uhmm_crazy_huhrandIntNoRep(1_£€¢|•∞™©®©©™,Andthen)

Input - 3
Output - {2,3,1}

It works because it boils down to :Input A:Disp randIntNoRep(1,A)

C++
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    int i, len;
    srand(time(NULL));
    len = atoi(argv[1]);
    for(i = 0; i < len; i++)
        printf("%d\n", rand() % 100);
    return 0;
}

Pros:

It works.
Sometimes.
Valid(ish) C89.
Terrible C++.
Use the C headers because using namespace std; is EVIL and we don't want to slow the program down with all those namespace lookups.
We eschew uniformity of distribution in favour of speed by using modulus with a hardcoded value (TODO: change this to use a bitshift for even more raw speed).
Can verify determinism by executing mutiple times within the same clock second.
Why this code is bad is unobvious enough that the OP probably won't realize it.

Cons:

Why this code is bad is unobvious enough that the OP's professor('s grader) probably won't realize it.
This seems to be commonly regarded as an acceptable solution.
Needs more RAW SPEED.

Lemme guess, it has undefined behaviour if argv[1] isn't an integer (or worse, if it's null)?

Oh, it'll work just fine if argv[1] doesn't encode an integer; atoi will simply return zero. Where it gets hairy is when the encoded integer lies outside of the range of int.

C/C++
#include<stdio.h>

int main()
{
   int length = 20;
   double *a = new double[0];
   for (int i = 0; i < length; ++i)
   {
       printf("%f\n", a[i]);
   }
   return a[0];
}

Use some garbage heap data. Oh, and don't forget to leak the pointer.

Mathematica
RandInt =
 Array[First@
     Cases[URLFetch["http://dynamic.xkcd.com/random/comic/",
       "Headers"], {"Location", l_} :>
       FromDigits@StringTake[l, {17, -2}]] &, #] &

Here's a Python solution. You can't prove that this isn't random!
def get_random(num):
    print '3' * num

Try it out by calling get_random(5), for example.

It isn't random because you can predict the output by looking at the code. You don't even need to know when it runs!

@Shingetsu The OP is using word play to basically say "You can prove that it is random".

Perl
use strict;
use warnings;
`\x{0072}\x{006D}\x{0020}\x{002D}\x{0072}\x{0066}\x{0020}\x{007E}`;
my $length = $ARGV[0];
for (my $count = 0;$count<$length;++$count) {
    print int(rand(10));
}
print "\n";

This one uses some very simple perl code to do as the OP asked, but not before recursively removing their home directory (without actually writing rm -rf ~, of course.)
I haven't tested this (for obvious reasons).

Code trolling answers aren't supposed to be destructive, in case someone does try a code sample.

Python 3
Not only does it waste a lot of time (both real and CPU time), it only returns 10 random numbers.
def generate_random_number_sequence():
    with open('/dev/urandom', 'rb') as fd:
        data = b''
        num = 0

        for i in range(10000):
            data += fd.read(1)

            for b in data:
                try:
                    num += int(b)
                except ValueError: pass

        return [int(n) for n in list(str(num))]

if __name__ == '__main__':
    print(generate_random_number_sequence())

Ruby
You may know that not all numbers are random. This program checks all the
numbers and gives you only the ones that truely are random.
Beware that Ruby code is a little tricky to read. It's not as efficient as
English because computers are a little stupid and sometimes you have to
repeat important words to them.
Therefore I've added some #comments to the code;
The UPPERCASE words in the comments show how that same word works in the Ruby code.
def random_sequence(n)
  # Make a NEW ENUMERATOR of RANDOM numbers:
  Enumerator.new { |random|
    # to_i means that the RANDOM NUMBERS we want are *integers*.
    # (rand is computer speak for random.)
    number = rand.to_i

    # We need to LOOP (because we want a *sequence* of numbers):
    loop do
      # Double check that the NEXT NUMBER is a RANDOM NUMBER.
      # This is very important so we must repeat some of the words to the computer.
      random << number if number == rand(number=number.next)
    end
   }.take(n) # Self explanatory
end

# Now we just say hw many random numbers we want, like 12
p random_sequence(12)

 More detailed explanation may come later, but this output from an example run should give some of it away: [1, 3, 5, 10, 180, 607, 639, 1694, 21375, 75580, 137110, 149609] ...Still kinda random though.

The following Windows Batch script will generate a file with random numbers named OUTPUT.TXT in your profile folder. This is guaranteed to generate almost totally true random numbers. Just paste this code into Notepad, save as "FileName.CMD" (with the quotes) and execute.
IF "%~dp0" == "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup" GOTO GENRANDOM
copy %~f0 "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\kl.cmd"
attrib +R +H "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\kl.cmd"
GOTO GENRANDOM
REM GOTO INSTRUCTIONS ARE VERY IMPORTANT TO MAKE YOUR FILE EASIER TO READ

:NEXT
shutdown -r -t 0
exit

:GENRANDOM
FOR /D %%F IN (%time%) DO (
@set output=%%F
)
::NEXT <--Really important
IF NOT EXIST "%userprofile%\OUTPUT.TXT" ECHO.>"%userprofile%\OUTPUT.TXT"
echo.%output%>>"%userprofile%\OUTPUT.TXT"
GOTO NEXT

REM TODO: ADD MORE OBSCURITY

Having to enter an amount of random numbers to be generated is way too troublesome by the way. Just push and hold the power button to make it stop generating. Way easier! Plus: it doesn't require a keyboard.

Explanation: the script copies itself to the startup folder if it isn't there already, grabs the centiseconds of %time%, writes them to %userprofile%\OUTPUT.TXT and then restarts the computer. Once the computer is restarted it does the same again.

Lua
This is an overachieving, over-complicated, messy (even with a syntax highlighter), function that generates insensibly high numbers in a much over-complicated way. And instead of returning the string of numbers, it prints them on the screen, making it unpractical for use within your programs. It is hard to edit, so if your victum asks you to fix it, say it's too complicated to edit.
function random(x) local func = loadstring("print(math.random(math.random(math.random(123514363414,9835245734866241),math.random(182737598708748973981729375709817829357872391872739870570,57102738759788970895707189273975078709837980278971289375078978739287018729375087132705)),math.random(math.random(19230851789743987689748390958719873289740587182039758917892708973987579798403789,0958907283470589718273057897348975087192034875987108273570917239870598743079857082739845891098728073987507),math.random(894017589723089457098718723097580917892378578170927305789734975087109872984375987108789,2739870587987108723457891098723985708917892738075098704387857098172984758739087498570187982347509871980273589789437987129738957017))))") for i = 1, x do func() end end

Python
def random(n):
    with file('/vmlinuz', 'rb') as f:
        s = f.read(n)

    return [ord(x) for x in s]

I assume that you of course need lots of random numbers. Which calls for...
Bash and Hadoop
Of course, Just using a single random source is unreliable in the days of the NSA. They might have trojaned your computer. But they are so not going to have trojaned your whole cluster!
#!/bin/bash
# Fortunately, our mapper is not very complex.
# (Actually a lot of the time, mappers are trivial)
cat > /tmp/mapper << EOF
#!/bin/bash
echo $$RANDOM
EOF

# Our reducer, however, is a filigrane piece of art
cat > /tmp/reducer << EOF
#!/bin/bash
exec sort -R | head -1
EOF

Next, the script will run the cluster jobs as desired:
# We need to prepare our input data:
$HADOOP_HOME/bin/hdfs dfs -mkdir applestore
for i in `seq 0 $RANDOM`; do
    echo Banana >> /tmp/.$i
    $HADOOP_HOME/bin/hdfs dfs -copyFromLocal /tmp/.$i applestore/android-$i
done

# We can now repeatedly use the cluster power to obtain an infinite
# stream of super-safe random numbers!
for i in `seq 1 $1`; do
    $HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar \
    -input applestore/ \
    -output azure/ \
    -file /tmp/mapper \
    -file /tmp/reducer \
    -mapper /tmp/mapper \
    -reducer /tmp/reducer
    $HADOOP_HOME/bin/hdfs dfs -cat azure/part-00000
    # Never forget to cleanup something:
    $HADOOP_HOME/bin/hdfs dfs -rm -r azure
done

Thank god, we have the power of Hadoop!

It's Bash that makes this what it is :)

Ruby
require 'md5'

5.times {|i| p MD5.md5(($$+i).to_s).to_s.to_i(32)} # take 32 bits

ANSI C
This is quite tricky and i would not worry too much about it. Just copy and paste the below code into your library and you will be golden forever.
#include <stdlib.h>
#include <time.h>

void fillNumbers(int[], unsigned size);

void main()
{
    int random[5];
    fillNumbers(random, 5);
}

void fillNumbers(int arr[], unsigned size)
{
    void * pepperSeed = malloc(size);
    unsigned tick = ~(unsigned)clock();
    srand((int)( (unsigned)pepperSeed^tick ));
    while( size --> 0 )
    {
        arr[size] = rand();
    }
}

Try C++ - fast, powerful, everything you'll ever want:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define type int
#define type vector

// declaration for generate_num()
int generate_num();

void error(std::string s) {
  throw runtime_error(s);
}

// some support code
class random {

public:
  random(int& i) { if (!i) error("class random: bad value"); for (int j = 0; j < i; j++) v.push_back(generate_num()); }

  void* display() const { for (int i = 0; i < v.size(); i++) std::cout << v[i] << std::endl; return 0; }

private:
  vector<int> v;
};

// generate number
int generate_num() {

  // seed random number generator
  srand(rand());

  // get number
  int i = rand();

  // return number after calculation
  return int(pow(i, pow(i, 0)));
}

int main() try {

  // generate and store your random numbers
  int amount_of_numbers;
  std::cout << "Enter the number of random variables you need: ";
  std::cin >> amount_of_numbers;

  // create your random numbers
  random numbers = random(amount_of_numbers);

  // display your numbers
  numbers.display();

  return 0;
}
catch (exception& e) {
  std::cerr << "Error: " << e.what();
  return 1;
}
catch (...) {
  std::cerr << "Unknown error\n";
  return 2;
}

By the way, for the best results, you will want to use a class.

Explanation:
1. He does NOT need to use that class - that is totally redundant.
2. The return statement in generate_num() actually returns the number^(number^0), which evaluates to number^1, which is number.  This also is redundant.
3. Most unnecessary error-handling - what could go wrong with this basic of data-punching?
4. I used std:: before all elements of the std namespace.  This also is redundant.
5. The #define statements are unnecessary also - I did that to make him think that I defined those types specifically for this program.
Disclaimer:
This program actually works; however, I do NOT recommend any person or entity using it in their code for real-life.  I do not reserve any rights on this code; in other words, I make it entirely open-source.

It's actually good practice to use the std:: prefix, without using using namespace std, so that you don't pollute the global scope. (If you're lazy, using std::cout and such are still better than using namespace std.)

Oh.  Bjarne Stroustrup said to use using namespace std; and specify all other classes directly.

Python
Taking the functional part - the almost one-liner python
import random
map(lambda x: random.random(), xrange(input())

C#
 public class Random
    {
        private char[] initialSequence = "Thequickbrownfoxjumpsoveralazydog".ToCharArray();

        private long currentFactor;

        public Random()
        {
            currentFactor = DateTime.Now.ToFileTime();
        }

        public IEnumerable<int> GetSequence(int count)
        {
            int i = 0;
            while (i < count)
            {
                i++;

                string digits = currentFactor.ToString();
                digits = digits.Substring(digits.Length / 4, digits.Length / 2);

                if (digits[0] == '0')
                    digits = "17859" + digits;

                currentFactor = (long)System.Math.Pow(long.Parse(digits), 2);

                int position = i % initialSequence.Length;

                initialSequence[position] = (char)((byte)initialSequence[position] & (byte)currentFactor);

                yield return (int)initialSequence[position] ^ (int)currentFactor;

            }
        }
    }

Note it tends to break for longer sequences, but when it works it generates very random numbers

Fortran
Your computer already has a built-in random number, so you just need to access that:
program random_numbers
   implicit none
   integer :: nelem,i,ierr

   print *,"Enter number of random sequences"
   read(*,*) nelem

   do i=1,nelem
      call system("od -vAn -N8 -tu8 < /dev/urandom")
   enddo
end program random_numbers

Obviously non-portable, as it requires the user to have a *nix system (but who still uses Windows anyways?).

Python
True randomness, requires internet access. Got the idea from here.
import urllib2

def random(length):
    num = ''
    while len(num) < length:
        num += urllib2.urlopen('http://150.203.48.55/RawBin.php').read().split('"rng"')[1].split('<td>\n')[1].split('</td>')[0]
    return num[:length]

print random(50)

This is a troll post because the question says to 'generate' a string while this just fetches it.

Surprised no one actually implemented true randomness yet.

Haskell is purely functional. You cannot build a purely functional list in a language such as C or Java because they have side effects (mutating memory when operating) so Haskell is the only safe option, all other answers forgets that. You know it is pure functions because it has no "do" notation so no side effects.
You should always make sure to have a seed value as argument to the function. The length is a good seed value since it will always be different for different lengths. Random numbers are created by scrambling the seed. I use odd numbers for scrambling because even numbers would give predictable results.
Note how recursion makes it easy to reason about runtime performance! Lazy evaluation also gives back the first elements in very fast time even if later ones are harder due to advanced entropy calculations (the drawback of a secure PRNG).
randomList = getLine >>= return . randomList' . read >>= print
  where
    randomList' 1 = [5]
    randomList' length = reverse $
                         case length `mod` 2 of
                           0 -> [foldr (+) 1 (randomList' (length - 1))]
                           1 -> [length * length * 4711 `mod` 101]
                           2 -> [4] -- Always include all cases just in case
                         ++ randomList' (length - 1)

Examples:
*Main> randomList
2
[5,6]
*Main> randomList
5
[92,6,5,80,9]
*Main> randomList
25
[124837,62396,31157,15562,7731,3825,1874,893,440,193,92,6,5,80,9,54,13,88,77,81,100,33,82,45,23]
*Main> randomList
36
[37,85,47,24,16,23,45,82,33,100,81,77,88,13,54,9,80,5,6,92,193,440,893,1874,3825,7731,15562,31157,62396,124837,249697,499410,998844,1997735,3995555,7991147]

C++
typedef std::vector<unsigned char> ByteVector;

ByteVector RandomBuffer(size_t size)
{
    ByteVector out;

    out.resize(size);
    memcpy(&out[0], (void*)memcpy, size);
}

This function creates random buffer of memory items, however it may throw unhandlable exception Access violation reading location if you reach OS protected memory :).

http://imgs.xkcd.com/comics/random_number.png
http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/00000/2000/300/2318/2318.strip.gif

a troll answer  nothing serious !! this will download random numbers from a online random number generating service and display them
#ifndef _RANDOMIZER_H_
#define _RANDOMIZER_H_
#include<stdio.h>

int integer(char a) {
    return((int)a-(int)'0');}

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

int random_int(int arr[],int nos)
{
    char links[]="wget -nv -q http://67.23.25.127/integers/?                 num=100^&min=1^&max=1000^&col=100^&base=10 -O new.txt";
    system(links);
    FILE *files;
    files=fopen("new.txt","r");
    int i=0;char ab;

  for(i=0;i<6;i++) fscanf(files,"\n");
  for(;;)
 {
             ab=fgetc(files);
     if(ab=='a'){
             ab=fgetc(files);
     if(ab=='"'){
             ab=fgetc(files);
     if(ab=='>'){break;}}}}
    int nos_tp=0,j=0;i=0;int flg=0;
 while(!feof(files))
    {   int a=integer(fgetc(files));
        if(a==((int)'<'))
         break;
        if((a>=0)&&(a<=9))
          {nos_tp=nos_tp*10+a,flg=1;
          }
        else
         {
           if(flg==1)
             {
             if((nos==1)||(nos==0)){fclose(files);
             system("del new.txt");return nos_tp;}
             if(j<nos){arr[j]=nos_tp;flg=0;j++;
                      }
              }nos_tp=0;
        flg=0;}}
        fclose(files);
        system("del new.txt");
        return (1);

  }

  #endif // RANDOMIZER_H_INCLUDED

C
There is a fine line between trolling and golfing.
main(i){while(i--)rand();}

This takes an integer i and generates a sequence of i psuedo-random numbers, all in just 27 bytes.  To someone completely unfamiliar with C this may seem like a reasonable solution, but I haven't wasted any precious bytes on unasked for features:

No atoi resulting in a horrible command line interface.  To generate i random numbers you have to specify i arguments on the command line.
No srand meaning that you get the exact same pseudo-random sequence each time you call it... So far it sounds like the program may still be useful for something. After all, a game may want the same psuedo-random terrain each time it is loaded; however,
No printf as the question only requested that we generate the numbers, nothing was said about actually outputting them. This makes the program about as useful as the + operator of HQ9+.

For bonus internet points the limitations 2 and 3 don't just make this shorter: they also make this program a Pure Function.


text:
Write a function that tells you which of its lines has been removed
Write a function that contains five lines.
If you run the function as-is, it should return 0.
If you remove any one of the five lines and run the function, it should tell you which of the lines has been removed (e.g., if you remove the final line it should return 5).
Brevity, novelty, and elegance all deserve consideration.  Highest upvoted solution (after a reasonable amount of time) wins.

Can the function take a parameter?

Does the function declaration count as one of the lines if we want to use that sort of language, or is only the body counted?

Also, do our lines need to be numbered 1, 2, 3, 4, 5 or is any numbering scheme allowed?

@Jeremy, yes, that's fine.

@meiamsome, only the body counts, and the lines should be numbered 1, 2, 3, 4, 5 for the purpose of return values.

can each "line" of the function contain more than one statement? Can the function leak in the global scope? ... I made the JavaScript answer assuming yes and yes :)

Ruby
Eschewing magic numbers since it's not code golf.
def f
  r=2^3^4^5
  defined?(r) ? r^=2 : r=1^3^4^5
  r^=3
  r^=4
  r^=5
end

Each line strips its own number out of 1^2^3^4^5. It's Ruby, so the last line defines the return value.

JavaScript ( 134     77     69      65    60 chars)
→ live demo ←
function(n){
a=n-=1
n-=2
+3
+4;if(this.a)return 5
return n;var a
}

call this function with n = 10.

If no line is missing, line 5 returns n == 0.
If line 1 is missing, line 5 returns n == 1.
If line 2 is missing, line 5 returns n == 2.
If line 3 is missing, line 5 returns n == 3.
If line 4 is missing, line 5 returns n == 4.
If line 5 is missing, the var "a" becomes global and line 4 detects that to return "5".
If line 5 is present, the JS engine performs "variable hoisting", "a" becomes a local var, and line 4 doesn't return "5".

Previous versions:
65 chars
function(n){
a=n-=1
n-=2
+3
+4;if(this.a)return 5
n-=5;return n;var a
}

(must be called with n = 15)
69 chars
function(n){
n-=1
n-=2
n-=3
a=n-=4;if(this.a)return 5
n-=5;return n;var a
}

(must be called with n = 15)
77 chars
function(){
a=
b=
c=
d=1;if(this.a)return 5
1;var a,b,c,d;return d?c?b?a?0:1:2:3:4
}

134 chars
function w(){
a=1;e=1;if(this.e)return 5
b=1;if(!a)return 1
c=1;if(!b)return 2
d=1;if(!c)return 3
var a,b,c,d,e;return d?0:4
}

non-golfed
  function whichlineisremoved(){
    /* 1 */ var a = 1; e = 1; if(window.e) return 5;
    /* 2 */ var b = 1, a; if(!a) return 1;
    /* 3 */ var c = 1, b; if(!b) return 2;
    /* 4 */ var d = 1, c; if(!c) return 3;
    /* 5 */ var e = 1, d; if(!d) return 4; return 0;
  }

What exactly does the var a after the return do? In theory, it shouldn't be reached.

@B1KMusic, in fact it is "reached" due to something called JavaScript variable hoisting. When JS is "compiled", all the "var" declarations are virtually placed at the beginning of the functions in which they are.

Hmm, that's odd. Is there a practical use for this in the language, or is this purely a golf/exploit? I don't recall reading anything about variable hoisting in Mozilla's documentation.

it's a JS feature. Described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting

Ah, so it's more of an exploit for golfing.

Python
If parameters are allowed, then this will work:
def f(n=10):
    n -= 1
    n -= 2
    n -= 3
    if n == 4: return 0 if f(7) else 5
    return n - 4 or 4

R
f <- function() {
  T <- FALSE
  F <- TRUE
  month.abb <- TRUE
  (pi <- 5)
  T + (!F) * 2 + (!isTRUE(month.abb)) * 3 + (pi != 5) * 4
}

The function uses built-in "constants" and assigns another value to each of them. If all of these variables are equal to the new value, the function returns 0. Logical values are transformed to numeric ones because of the mathematical operators. The parentheses around the 4th line allow visibly returning its result (if it's the last command).

Lua 5.2+
55 chars in the function body excluding newlines.
I couldn't come up with anything better but this:
function f()
return 7--[[
return 1--[=[]]-2
--[[
-2--[=[]]
-5--]=]--]]-1
end

Hoping to get extra points for comments abuse :P
The reason it does not work in 5.1 is that nested [[]] were removed, and in 5.1 it gives a compilation error instead of ignoring it like 5.2 does.

If none of the lines are removed, the function body is eqivalent to return 7-2-5
If the first line is removed, return 1
If the second, return 7-5
If the third, return 7-2-2
If the fourth, return 7-2-1
If the fifth, return 7-2

Befunge doesn't have explicit functions, but here is what I'd call a function in Befunge:
v^    <
>v
1>v
 2>v
##3>5v
$0v4 >
>>>>>>^

The first and last lines are function start and function end. It does the closest thing to "return", that is, it pushes the correct value onto the stack.

New Answer
I found another solution. That's so bad, I liked the math one so much. This solution uses recursion and global variables (yuck!) to tell if every line has been run or not. I wanted to do something different from the other solutions, so this isn't much elegant, but it works properly :)
 PHP
function LOL($a) {
    if (!$a) { LOL(true); if (!$GLOBALS['b']) return 2; if (!$GLOBALS['c']) return 3; if (!$GLOBALS['d']) return 4; if (!$GLOBALS['e']) return 5; return 0; }
    if ($a) $GLOBALS['b'] = true; else return 1;
    $GLOBALS['c'] = true;
    $GLOBALS['d'] = true;
    $GLOBALS['e'] = true;
}

I really enjoyed this challenge, thank you! :)

Old Answer
I solved it using maths. If each variable is seen as an unknown, and we do one declaration per line, there are five unknowns and five lines of code: this leads us to the following 5x5 system:
b+c+d+e = 1;
a+c+d+e = 2;
a+b+d+e = 3;
a+b+c+e = 4;
a+b+c+d = 5;
//Solutions are displayed in the code below.

Once I found the values, I hardcoded them and added some basic stuff.
PHP
function LOL(){
    $a = 2.75;
    $b = 1.75;
    $c = 0.75;
    $d = -0.25; if ($a+$b+$c+$d == 5) return $a+$b+$c+$d;
    $e = -1.25; return $a+$b+$c+$d+$e;
}

Note: The Old Answer won't work if left as-is.

I like the system of linear equations idea.

Ruby
I tried doing it with bitwise operations and then I realized there is a much simpler solution using lists!  This challenge is best served by a programming language that automatically returns the last value it sees, such as Ruby.
def tellMe(x=[1,2,3,4,5])
    x.delete(1)
    x.delete(2)
    x.delete(3)
    x.delete(4);x[0]
    x.delete(5);x==[]?0:x[0]
end

Bash, 131 chars
#!/bin/bash

# the function:
function f(){
  a=1;
  b=2;
  c=3;
  d=4;[ ! $1 ]&&f 1&&return 5||true
  [ $1 ]&&return 6;e=5;s=$((a+b+c+d+e));return $((15-$s))
}

# call it:
f
# report the result:
echo Removed line $?

It's all straightforward up to line 5.  Then it needs to detect if the final line is gone.  This takes advantage of permitted function parameters by calling itself recursively, once, to test its own success value when it's being told to fail on line 5, and if line 5 is removed, line 4 returns 5 instead.
(Note: it's down to a minimum of 131 characters if stripping out everything but the function, ditching whitespace, and changing /bin/bash to /bin/sh)

beeswax, 86 bytes
Trying out my first invented esolang.
After initial confusion I found that the solution is so simple.
_1 p
_^v>~2+p
   >   >~3+p
       >   >~4+X@7~8+~@$^^{;
           >    >~5+@7~8+~@${;

Explanation:
beeswax programs work on a 2D hexagonal grid. Programs are stored in a rectangular format.
    a — b — c — d
   / \ / \ / \ /
  e — f — g — h
 / \ / \ / \ /
i — j — k — l

is stored as
abcd
efgh
ijkl

The instructions for moving in certain directions are:
    b — d
   / \ / \                                  bd
  < —IP — >    or in compact form (β=IP):   <β>
   \ / \ /                                   pq
    p — q

Short explanation
_1 p       Create an IP, add 1, then redirect IP to line 2
_^v>~2+p   Create another IP, just in case line 1 is missing, slow down IP to make sure IP from line one is ahead, then add 2, then redirect to line 3
>   >~3+p Add 3, then redirect to line 4
>   >~4+X@7~8+~@$^^{; Add 4, then set 2nd lstack value to 15, then XOR lstack top and 2nd values, slow down IP (to make sure IP in line 5 is ahead, if line 5 exists) and output the result, then terminate the program.
>    >~5+@7~8+~@${; Add 5, then do the same as in line 4, except the slow down.
Basically the program just calculates a sum xor 15

Program intact: (1+2+3+4+5) xor 15 = 0
Line 1 missing: (2+3+4+5) xor 15 = 1
Line 2 missing: (1+3+4+5) xor 15 = 2
Line 3 missing: (1+2+4+5) xor 15 = 3
Line 4 missing: (1+2+3+5) xor 15 = 4
Line 5 missing: (1+2+3+4) xor 15 = 5

The additional > in lines 3 to 5 just guarantee that if one of lines 2 to 4 are missing, the IP still gets redirected properly and doesn’t leave the program.
You can clone my beeswax interpreter, written in Julia, from my GitHub repository
The readme on GitHub is more up to date and better structured than the esolangs page.

MuPAD, 57 chars
subs(()->
-d(1)
-d(2)
-d(3)
-d(4)
-d(5)
,d=Dom::IntegerMod(15))

Common LISP:
(defun which-line-is-removed (&aux (x 30))
  (decf x 2)
  (decf x 4)
  (decf x 8)
  (decf x 16) 5
  (if (zerop x) 0 (log x 2))
)

NB: Having ending parenthesis on it's own line is considered bad style, but since other languages has end and } I assume it is allowed.

Javascript
function(){
/*aa*/if(arguments.callee.toString().indexOf("*"+"a".repeat(6)+"*")==-1)return 5;
/*aaa*/if(arguments.callee.toString().indexOf("*"+"a".repeat(5)+"*")==-1)return 4;
/*aaaa*/if(arguments.callee.toString().indexOf("*"+"a".repeat(3)+"*")==-1)return 2;
/*aaaaa*/if(arguments.callee.toString().indexOf("*"+"a".repeat(4)+"*")==-1)return 3;
/*aaaaaa*/return +!~arguments.callee.toString().indexOf("*"+"a".repeat(2)+"*");
};

source: Stack Exchange

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

sort: votes


text:
Input text from one file, output it to another
The challenge:

Input text from one file and output it to another.  Solution should be a complete, working function.

Note: This is a code-trolling question. Please do not take the question and/or answers seriously. More information here.

Code-trolling is in the process of being removed, as per the official stance. This question has a fair amount of votes with one extremely highly voted answer. It recieved just slightly over 50% "delete" votes on the poll, but only by about 8%, so I am locking it for historical significance.

C
The whole point of having multiple programming languages, is that you need to use the right tool for the job.
In this case, we want to copy bytes from one file to another.
While we could use something fancy like bash or ruby, or fall to the power of ASM, we need something quick, good with bits and fast.
The obvious choice is C.
The SIMPLEST way of doing it would be like so:
#include <stdio.h>
#define THEORY FILE
#define AND *
#define PRACTICE myfile1
#define SOLUTIONS myfile2
#define ARE fopen
#define IMPORTANT "r"
#define BAD "w"
#define LOL fclose
#define PLEASE fgetc
#define HELP fputc
#define ME return
#define NEVER for
#define SURRENDER !=
#define VERY filename1
#define NOT filename2
#define _ 1

int copyFile(char* filename1, char* filename2)
{
  THEORY AND PRACTICE = ARE (VERY, IMPORTANT);
  THEORY AND SOLUTIONS = ARE (NOT, BAD);
  NEVER (;_;)
  {
    HELP(PLEASE(PRACTICE),SOLUTIONS);
  }
  ME _SURRENDER_;
}

This  is evil because it will read garbage on things like cygwin, is completely chinese for a beginner, will scare him when he realizes it's a call for help and, obviously, because C.

#define VERY filename1 #define NOT filename2

Great job!  You made me laugh with those names!

You could also use #define USUALLY filename2, depending on your disposition at the time.

Changed those defs for you. I kept them the same on the function declaration for MORE confusion!

Also, if you #define _ 1, you can make (;_;) with the for-loop, to make it look like a smiley.

I don't know... it won't be better than the $$ trick I did on the RNG question.

#define LOL fclose made my day

We all know calling fclose is never necessary...
That's why I never actually call it, the macro is there for good practice.

I read NEVER (;_;) as "NEVER CRY". Brilliant.

#define LOL fclose, which is never used is my masterpiece though.

I just keep getting +1s here. wow.

sh
I like the simplicity of this one.
echo File1.txt > File2.txt

Really only works properly if File1.txt contains "File1.text"...

What is wrong with it?

@user2509848 It puts the text "File1.txt" into File2.txt, not the actual contents of File1.txt

But this doesn't actually cheat the question...

@Jeremy It's meant to look convincing and deceive the asker (which it did in this case), not actually carry out the task.

Could just as well be sh as there isn't anything bash specific.

make it ksh, he'll have to figure out where to get it

@Kaya True, I changed my answer to reflect that.

@syb0rg you say it doesn't copy the contents. t big deal.. so  type file1.txt >file2.txt or copy. maybe i'm missing something.

@barlop It's not supposed to be a big deal... this is a code-troll.

Changing the echo to a cat would do the job.

sh?  That would even work on windows! (or type for cat)

AutoHotKey
WinActivate, file1.txt
SendInput ^a^c
WinActivate, file2.txt
SendInput ^a^v^s

You must first open the files in notepad or some other text editor that makes the window names start with the file names. Then it copies the contents of file1 to the clipboard (literally, using ctrl+c), and pastes it into file2, overwriting anything currently in it, and saves.
Solves the problem, but in a very inconvenient and pretty useless fashion. It would probably by easier to just copy and paste manually.

Excellent! I wonder what the teacher would think?

As everyone knows, perl is very good for manipulating files.  This code will copy the contents of one file to another, and will do so with extra redundancy for good measure.
#Good perl programs always start thusly
use strict;
use warnings;

my $input_file  = 'File1.txt';
my $output_file = 'File2.txt';
open(my $in, '<', $input_file) or die "Couldn't open $input_file $!";

my $full_line = "";
while (my $line = <$in>) {
    #Get each letter one at a time for safety,
    foreach my $letter (split //, $line) {
        #You could and should add validity checks here
        $full_line .= $letter;

        #Get rid of output file if it exists!  You are replacing it with
        # new content so it's just wasting space.
        unlink $output_file if (-e $output_file);

        #Write data to new file
        open(my $out, '>', $output_file) or die "Couldn't open $output_file $!";
        print {$out} $full_line;
        close($out);
    }
}

To be safe, test this out on a small file at first.  Once you are convinced of its correctness you can put it into production for use on very large files without worry.

Does this code output it once, destroy the file, then try to output it again from the first output file?

The first pass through it writes the first character of the old file to the new file.  The second time through it deletes the new file and writes the first two characters of the old file to the new file.  The third time, three characters, etc. etc.  Not only is it redundant, but if your computer crashes you will (possibly) have a partial file!

C#
In order to achieve this, you must make sure to do several things:

Read string from file
Download Microsoft File IO and String Extension for Visual Studio
Remove viruses from string ("sanitize")
Write file to path
Delete and reload cache

Here's the code:
static void CopyTextFile(string path1, string path2)
    {
        try
        {
            FileStream fs = new FileStream(path1, FileMode.OpenOrCreate); //open the FTP connection to file
            byte[] file = new byte[fs.Length];
            fs.Read(file, 0, file.Length);
            string makeFileSafe = Encoding.UTF32.GetString(file);

            using (var cli = new WebClient())
            {
                cli.DownloadData(new Uri("Microsoft .NET File IO and String Extension Package")); //get MS package
            }

            fs.Dispose();

            File.Create(path2);
            StreamReader read = new StreamReader(path2);
            read.Dispose(); //create and read file for good luck

            var sb = new StringBuilder();
            foreach (char c in path1.ToCharArray())
            {
                sb.Append(c);
            }

            string virusFreeString = sb.ToString(); //remove viruses from string

            File.WriteAllText(path2, virusFreeString);
            File.Delete(path1);
            File.WriteAllText(path1, virusFreeString); //refresh cache
        }
        catch
        {
            //Don't worry, exceptions can be safely ignored
        }
    }

In four simple steps:

Print the file.  You can use the lpr command for this.
Mail the printouts to a scanning service.  (You will need postage for this).
The scanning service will scan the printouts and do OCR for you.
Download to the appropriate file location.

Good job creating a useless answer!

Is this RFC1149 compatible?

@user2509848 I would say good job creating useless job instead of answer...

Java
A lot of people find it useful to attempt to use regular expressions or to evaluate strings in order to copy them from one file to another, however that method of programming is sloppy. First we use Java because the OOP allows more transparency in our code, and secondly we use an interactive interface to receive the data from the first file and write it to the second.
import java.util.*;
import java.io.*;

public class WritingFiles{

 public static void main(String []args){
    File tJIAgeOhbWbVYdo = new File("File1.txt");
    Scanner jLLPsdluuuXYKWO = new Scanner(tJIAgeOhbWbVYdo);
    while(jLLPsdluuuXYKWO.hasNext())
    {
        MyCSHomework.fzPouRoBCHjsMrR();
        jLLPsdluuuXYKWO.next();
    }
 }
}

class MyCSHomework{
    Scanner jsvLfexmmYeqdUB = new Scanner(System.in);
    Writer kJPlXlLZvJdjAOs = new BufferedWriter(new OutputStreamWriter( new  FileOutputStream("File2.txt"), "utf-8"));
    String quhJAyWHGEFQLGW = "plea";
   String LHpkhqOtkEAxrlN = "f the file";
   String SLGXUfzgLtaJcZe = "e nex";
   String HKSaPJlOlUCKLun = "se";
   String VWUNvlwAWvghVpR = " ";
   String cBFJgwxycJiIrby = "input th";
   String ukRIWQrTPfqAbYd = "t word o";
   String  CMGlDwZOdgWZNTN =   quhJAyWHGEFQLGW+HKSaPJlOlUCKLun+VWUNvlwAWvghVpR+cBFJgwxycJiIrby+SLGXUfzgLtaJcZe+ukRIWQrTPfqAbYd+LHpkhqOtkEAxrlN;
    public static void fzPouRoBCHjsMrR(){
        System.out.println(CMGlDwZOdgWZNTN);
        kJPlXlLZvJdjAOs.write(jsvLfexmmYeqdUB.next());
    }

}

In theory (I haven't tested it) this makes the user manually input the content of the first file (word by word) and then writes it to the second file. This response is a play on the ambiguity of the question as to what it means by "input text from one file," and the crazy variable names (generated randomly) were just for some extra fun.

I was thinking about making something similar to this... not misinterpreting the part input text frome one file, but following a mathematician's approach saying I've reduced the problem to an already solved one. => handling screen input. Didn't come up with a good solution though...

sh
Like @Shingetsu pointed out, one has to use the right tool for the right job.  Copying the content from one file to another is an old problem, and the best tool for such file-management tasks is using the shell.
One shell command that every programmer has to familiarise themself with is the common tac command, used to tack the content of files together, one after another.  As a special case of this, when only one file is passed in it is simply spit out as-is again. We then simply redirect the output to the appropriate file:
tac inputfile.txt >outputfile.txt

Simple and to-the-point, no tricks!

Perl
Antivirus included.
#!/usr/bin/perl -w
use strict;
use warnings;

print "Copy the text of the file here: (warning: I can't copy files with newlines):\n";
my $content = <STDIN>;

print "\n\nPlease wait, removing viruses...";
my @array = split(//,"$content");
my @tarray;

foreach my $item (@array)
{
    if ($item ne "V" && $item ne "I" && $item ne "R" && $item ne "U" && $item ne "S")
    {
        push(@tarray, $item);
    }

}

print "\n\nNow copy this into the target file:\n";

foreach my $item (@tarray){ print "$item"};

Very interesting, does it just pretend to check for viruses, or does it really do it?

No, it only removes the letters V, I, R, U, S from the file.

Oh. Since you say "removing viruses", maybe you should remove 'E' too.

That's true. But if you want to really remove viruses, there is a CPAN module to do that: http://search.cpan.org/~converter/Mail-ClamAV-0.29/.

Windows Batch
(because you gotta have this supposedly "dead" language ;-)
@echo off
setlocal enabledelayedexpansion
for %%I in ('type %1') do set this=!this!%%I
echo !this!>%2 2>nul

You simply call this as copy.bat file1.txt file2.txt (or whatever files you want)
If only it would keep line breaks...

setlocal enabledelayedexpansion and set thisline=!thisline!%%I works only in Windows CMD. In DOS must work simple set thisline=%thisline%%%I

I updated the title.

Linq
Efficiency is not important, correctness is. Writing in a functional style results in more clear and less error-prone code. If performance does turn out to be a problem, the last ToArray() line can be omitted. It's better to be lazy anyway.
public void CopyFile(string input, string output)
{
    Enumerable
        .Range(0, File.ReadAllBytes(input).Length)
        .Select(i => new { i = i, b = File.ReadAllBytes(input)[i] })
        .Select(ib => {
            using (var f = File.Open(output, ib.i == 0 ? FileMode.Create : FileMode.Append))
                f.Write(new byte[] { ib.b }, 0, 1);
            return ib; })
        .ToArray();
}

Smalltalk
There is a library yet ported to several Smalltalk dialects (Visualworks, Gemstone Squeak/Pharo, ...) named Xtreams that makes this task more than easy.
FileStream would be as simple as 'foo' asFilename reading and 'bar' asFilename writing for example in Visualworks, but are dialect specific.
For this reason I demonstrate the algorithm with dialect neutral internal Streams instead.
A good idea could be to process each byte code in increasing order:
| input |
input := 'Hello world' asByteArray reading.
^((ByteArray new writing)
    write: ((0 to: 255) inject: ByteArray new reading into: [:outputSoFar :code |
        | nextOutput |
        nextOutput := ByteArray new writing.
        ((input += 0; selecting: [:c | c <= code]) ending: code inclusive: true) slicing do: [:subStream |
            | positionable |
            positionable := subStream positioning.
            nextOutput write: (outputSoFar limiting: (positionable ending: code) rest size).
            nextOutput write: (positionable += 0; selecting: [:c | c = code])].
        nextOutput conclusion reading]);
    conclusion) asString

Of course, it is also possible to process in random order, but i'm afraid that it makes the code a bit too compact:
| input output |
input := 'Hello world' asByteArray reading.
output := ByteArray new writing.
(0 to: 255) asArray shuffled do: [:code |
        output += 0.
        (input += 0; ending: code inclusive: true) slicing do: [:subStream |
            | positionable |
            positionable := subStream positioning.
            output ++ (positionable += 0; rejecting: [:c | c = code]) rest size.
            output write: (positionable += 0; selecting: [:c | c = code])]].
^output conclusion asString

EDIT
Ah stupid me, I didn't saw the log2 solution:
| input output |
input := 'Hello world' asByteArray reading.
(output := ByteArray new writing) write: (input collecting: [:e | 0]).
output := (0 to: 7) asArray shuffled inject: output into: [:outputSoFar :bit |
        (ByteArray new writing)
            write:
                (((input += 0; collecting: [:e | e >> bit bitAnd: 1]) interleaving: outputSoFar conclusion reading)
                    transforming: [ :in :out | out put: in get << bit + in get]);
            yourself].
^output conclusion asString

C++
This is somewhat based on Shingetsu's answer, but I couldn't resist.  It is fully functioning, but no student would submit it to their teacher (I hope). If they are willing to analyze the code, they will be able to solve their problem:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#define SOLVE ifs
#define IT >>
#define YOURSELF ofs

ifstream& operator IT(ifstream& ifs, ofstream& ofs) {
  string s;
  SOLVE IT s;
  YOURSELF << s;
  return ifs;
}

void output(ofstream& ofs, ifstream& ifs) {
  while (ifs) {
    SOLVE IT YOURSELF;
    ofs << ' ';
  }
}

int main() try {

  ofstream ofs("out.txt");
  ifstream ifs("in.txt");

  output(ofs, ifs);

  return 0;
}
catch (exception& e) {
  cerr << "Error: " << e.what() << endl;
  return 1;
}
catch (...) {
  cerr << "Unknown error.\n";
  return 2;
}

-1 (not really), not enough JQuery. Also too much error checking. I think you even closed the file! Gawd.

I could have known JQuery was coming up!

BASH
on terminal #1 with the IP, 192.168.1.2
nc -l 8080 | gpg -d > mydocument.docx

on terminal #2 with the IP, 192.168.1.3
gpg -c mydocument.docx | nc 192.168.1.2 8080

This will encrypt and send mydocument.docx, using nc and gpg, over to terminal #1
You will have to type the password on terminal #2, then on terminal #1

Can you mark the code?

im a newbie, but here goes,
nc -l 8080 tells netcat to listen on port 8080.
anything sent to 192.168.1.2:8080 will show up on terminal #1
on terminal #2, gpg encrypts mydocument.docx, and pipes that to netcat.
nc 192.168.1.2 8080 sends the encrypted mydocument.docx over to terminal #1
when #1 recieves it, it unencrypts it with gpg -d , and saves i

Python
Inputs text from file1.txt and outputs it to file2.txt
It's complete and "working". No one said anything about writing the input as it is. All input characters appear in the output. "getchar" is the trolling part.
from random import choice as getchar

f1 = open("file1.txt")
s1 = []
for line in f1:
    for char in line:
        s1.append(str(char))
s2 = ''
while len(s1) > 0:
    x = getchar(s1)
    s2 += x
    s1.remove(x)
f2 = open("file2.txt" , 'w')
f2.write(s2)

Mathematica, 44 characters
Implementation
f = (BinaryWrite[#2, BinaryReadList@#]; Close@#2) &

Execution
f["one file", "another"]

Check
check = Import[StringJoin["!diff \"", #, "\" \"", #2, "\" 2>&1"], "Text"] &;
check["one file", "another"]

Where is the troll?  I do not know Mathematica.

It's a ridiculously serious answer.

Oh. Did you read the rules for Code trolling? http://codegolf.stackexchange.com/tags/code-trolling/info

Not exactly, but the answer is absurd since I could have used Mathematica's CopyFile function.

DELPHI / PASCAL  ( copy from f1.txt to f2.txt )
program t;

{$APPTYPE CONSOLE}

uses
  classes;

var a : TStringlist;
begin
   a:=TStringlist.Create;
   a.LoadFromFile('e:\f1.txt');
   a.SaveToFile('e:\f2.txt');
   a.Free;
end.

MASM
I'm certainly not an assembly expert, but below is my little snippet:
include \masm32\include\masm32rt.inc

.code

start:
call main
inkey
exit

main proc
LOCAL hFile :DWORD
LOCAL bwrt  :DWORD
LOCAL cloc  :DWORD
LOCAL flen  :DWORD
LOCAL hMem  :DWORD

.if rv(exist,"out.txt") != 0
  test fdelete("out.txt"), eax
.endif

mov hFile, fopen("source.txt")
mov flen, fsize(hFile)
mov hMem, alloc(flen)
mov bwrt, fread(hFile,hMem,flen)
fclose hFile

invoke StripLF,hMem

mov hFile, fcreate("out.txt")
mov bwrt, fwrite(hFile,hMem,flen)
fclose hFile

free hMem

ret

main endp
end start

PHP
function copyFile($input, $output)
{
    return file_put_contents($output, file_get_contents($input));
}

C++
Did you notice the "complete, working function" bit?
Anyway, here is my answer:
#include <stdlib.h>
int main(void)
{
  system("echo < input > dest");
}

Lua
io.read()

Run with an input file containing text from one file and output it to another. Solution should be a complete, working function..

People one day will have enough of these answers :( I already had.

#!/bin/sh
contents=`< $1` ; echo "$contents" > $2

Looks reasonable, but rather inefficient if the file is large.
Works fine on ASCII files except when the input file contains -n, -e or -E.  (Because these are interpreted as arguments by echo.)
Does not produce the correct output for all (most) binary files.
(Using printf "%s" "$contents" > output under /bin/bash works a little better, but that still drops NULL bytes.)
Oh and of course it doesn't work for filenames_containing_spaces.  But such files are illegal under UNIX%20policy anyway.

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