Say Happy Birthday with Code!

Most people just say “Happy Birthday” to each other over social networks like Facebook and Twitter with the same 14 predictable letters.   Why not say it with code?   If you’re a developer you already understand.   Smile   Before you ask … Yes, I really did write and run the QBasic 4.5 version in 16-bit mode running www.DosBox.com on Windows 7 x64.   Oh, and no it’s not my birthday.

 

With PowerShell

1..4 | % {if ($_ -ne 3) {Write-Host "Happy Birthday to You!"} else {"Happy Birthday Dear Jeff"}}

With C# Console Application

for (int i = 0; i <= 3; i++) { Console.WriteLine(((i == 2) ? "Happy Birthday dear Jeff" : "Happy Birthday to You!")); }

With JavaScript

With Command Prompt

@ECHO OFF
FOR %%A IN (1 1 2 1)
DO (
IF %%A == 1 ECHO "Happy Birthday to You!"
IF %%A == 2 ECHO "Happy Birthday dear Jeff"
) 
:EOF

With QBasic 4.5  (oh yes I did!)

CLS
FOR x = 1 TO 4
        IF x = 3 THEN
                PRINT "Happy Birthday dear Jeff!"
        ELSE
                PRINT "Happy Birthday to You!"
        END IF
NEXT x
FOR x = 37 TO 1000
        SOUND x, 1
NEXT x

 

image

image

image

image

Return to Top ▲Return to Top ▲