Python
Code:#!/usr/bin/env python if __name__ == "__main__": name = raw_input("Hi! What's your name? ") print "Hello, %s! Welcome to Ubuntu!" % (name or "Nameless thing")
Python
Code:#!/usr/bin/env python if __name__ == "__main__": name = raw_input("Hi! What's your name? ") print "Hello, %s! Welcome to Ubuntu!" % (name or "Nameless thing")
RUBY
Code:print "What is your name?" your_name = gets() puts "hello"+your_name+"welcome to Ubuntu"
TCL
Code:#!/usr/bin/env tclsh puts -nonewline "Hi! What's your name? " flush stdout gets stdin name puts "Hello, $name! Welcome to Ubuntu!"
FORTRAN 77
FORTRAN 90Code:PROGRAM HELLOUBUNTU C VARIABLE DECLARATIONS CHARACTER(25) MYNAME C GET USER INPUT (NAME) PRINT *, "HI! WHAT'S YOUR NAME?" READ *, MYNAME C OUTPUT MESSAGE PRINT, "HELLO ", MYNAME, "! WELCOME TO UBUNTU!" END
Code:PROGRAM HELLOUBUNTU ! VARIABLE DECLARATIONS CHARACTER(25) :: MYNAME WRITE(*,*) "HI, WHAT'S YOUR NAME?" READ(*,*) MYNAME WRITE(*,*) "HELLO ", TRIM(MYNAME), "! WELCOME TO UBUNTU!" ! END PROGRAM STOP END PROGRAM
Last edited by xtacocorex; July 22nd, 2007 at 02:32 AM. Reason: Screwed up F77 write statements
#399784 | Ubuntu User #287
*** If you're going to program, install the damn build-essential package ***
There is no such thing as Ubuntu specific programming
Save the electrons - if you quote, trim!
Haskell
OCamlCode:main :: IO () main = do putStr "Hello. What's your name? " name <- getLine putStrLn $ "Welcome to Ubuntu, " ++ name ++ "."
DCode:let main () = print_string "Hello. What's your name? "; let name = read_line () in Printf.printf "Welcome to Ubuntu, %s\n." name let _ = main ()
Code:import tango.io.Console, tango.io.Stdout; char[] readName( char[] prompt="Hello. What's your name? " ) { Cout( prompt ).flush; char[] input; Cin.readln( input ); return input; } void main() { Stdout.formatln( "Welcome to Ubuntu, {0}", readName() ); }
Last edited by Jessehk; July 10th, 2007 at 09:46 PM.
Basic
Can't believe noone has done basic yet!
Code:10 input "Hello! What is your name?",name$ 20 print "Welcome to Ubuntu, "; name$
C#
Code:public class HelloUbuntu { public static void Main() { System.Console.WriteLine("Hello! What is your name?"); string name = System.Console.ReadLine(); System.Console.WriteLine("Hello, {0}! Welcome to Ubuntu!", name); } }
Last edited by Occasionally Correct; July 10th, 2007 at 10:40 PM.
Objective C (more complicated than it has to be)
Code:#include <Foundation/Foundation.h> #include <stdio.h> @interface User : NSObject { char *name; char *os; } - (void) setOS: (char *) os; - (void) setUser: (char *) name; - (void) welcome; @end @implementation User - (void) setOS: (char *) osys { os = osys; } - (void) setUser: (char *) username { name = username; } - (void) welcome { printf ("Hello, %s! Welcome to %s\n", name, os); } @end int main () { User *thedoc; char name[100]; char *os; printf ("What is your name? "); fgets (name, 100, stdin); name[strlen(name) - 1] = '\0'; os = "Ubuntu"; thedoc = [User new]; [thedoc setOS: os]; [thedoc setUser: name]; [thedoc welcome]; }
Pascal
Code:program Ubuntu; var name : string; begin write('Whats your name?'); readln(name); write(name, ', welcome to Ubuntu!'); end.
Bookmarks