# Play a sound, any sound [closed]

Your program has to make the computer produce a sound, any sound.

Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins.

• The program should run on a reasonable, not too uncommon personal computer.
• Opening a pop-up, message box, etc. (for example, on a web page) does not count, as they might or might not produce a sound, depending on a lot of settings.
• Just entering a wrong command or invalid character on a console and receiving a warning beep does not count, just as the compiler/interpreter/OS beeping on an error or crash does not count either. Your code must be a valid program.
• ^G aka system bell or OS beep may be suppressed on many systems too (e.g. switched to be a visible "bell") and should be handled like sounds of popus and so on too: Not a valid solution.
– user19214
Jun 17, 2014 at 21:43
• Every program that prints "\a" to a terminal fails if xterm uses a visible bell. Jun 18, 2014 at 23:42
• rm / will cause a lot of screaming. Jun 22, 2014 at 17:23
• My left fan has been dying noisily for a while. Would that be a valid 0 bit answer? Sep 29, 2015 at 0:11
• I think this question should be reopened. The joke answers that rely on the fan spinning or the CD tray opening are invalid, since the question says "play a sound". Seems pretty clear to me that the output needs to come from the speakers as a result of the program, not the OS or the user or the hardware. Dec 2, 2016 at 19:40

## R, 7

alert()


but sadly I think this is just a wrapper for printing the bell character.

In AppleScript ; 4 characters

beep


[ This is so short that my answer firstly did not reach the minimum length to be posted ! ]

## Ruby, 8 chars

puts ?\a


## ><>, 2-3 chars

7o;


or with infinite loop:

7o


## Autohotkey

I found my answer in the Documentation on the Autohotkey Docs.

SoundBeep


# Fortran 95, 18 chars

print*,char(7);end


Produces a bell sound

# C#, 72 bytes

class Program{public void main(string[]args){System.Console.Beep(500);}}


# C on linux

#include <fcntl.h>
#include <linux/cdrom.h>
#include <sys/ioctl.h>

int main() {
ioctl(open("/dev/sdb", O_RDONLY), CDROMEJECT);
}


Opens the CD-ROM door.

You may need to change sdb to whatever your optical drive's device is.