Hello world/Text: Difference between revisions
(→[[C plus plus|C++]]: Fixed VC++ compiler link) |
(→[[Visual Basic .NET]]: Fixed compiler link.) |
||
Line 247: | Line 247: | ||
[[Category:Visual Basic]] |
[[Category:Visual Basic]] |
||
'''Compiler |
'''Compiler:''' [[Visual Basic]] 2005 |
||
Module GoodbyeWorld |
Module GoodbyeWorld |
||
Sub Main() |
Sub Main() |
Revision as of 14:25, 1 February 2007
You are encouraged to solve this task according to the task description, using any language you may know.
In the User Output task, the goal is to display the string "Goodbye, World!"
Text Terminal
Ada
Compiler: GCC 4.1.2
with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin Put_Line ("Goodbye, World!"); end Main;
BASIC
Compiler: BASICA
10 print "Goodbye World!"
C
Compiler Suite: GCC 4.0.1
#include <stdio.h> int main(int argc, char **argv) { printf("Goodbye, World!\n"); return 0; }
C++
Compiler Suite: GCC 4.1.2, Visual C++ 2005
#include <iostream> using std::cout; using std::endl; int main () { cout << "Goodbye, World!" << endl; return 0; }
C#
Compiler Suite: All should work, tested on Mono 1.2
System.Console.WriteLine("Goodbye, World!");
IDL
print,'Goodbye World'
Java
Compiler: any Java compiler should do
System.out.println("Goodbye, World!");
Lua
Interpreter: Lua 5.1.1
print("Goodbye, World!")
or:
print "Goodbye, World!"
In Lua, parentheses are optional for function calls when there is only one argument and this argument is either a string or a table constructor.
mIRC Scripting Language
Interpreter: mIRC
alias saygoodbye { echo -a Goodbye! }
OCaml
print_endline "Goodbye, World!"
Pascal
Compiler: Free Pascal
program byeworld; begin writeln('Goodbye, World!'); end.
Perl
Interpreter: Perl 5.8.8
print "Goodbye, World!\n";
PHP
echo "Goodbye, World!\n";
Python
Interpreter: Python 2.4
print "Goodbye, World!"
Ruby
Interpreter: Ruby 1.8.4
puts "Goodbye, World!"
or
$stdout.puts "Goodbye, World!"
Tcl
Output to terminal:
puts "Goodbye, World"
Output to file:
puts $fileID "Goodbye, World"
UNIX Shell
Interpreter: Bourne Again SHell (bash)
#!/bin/bash echo "Goodbye World!"
GUI
ActionScript
trace("Goodbye, World!");
AppleScript
display dialog "Goodbye, World!"
C++
Compiler Suite: GCC 3.3.5
Library: Gtk
#include <gtkmm.h> int main(int argc, char *argv[]) { Gtk::Main app(argc, argv); Gtk::MessageDialog msg("Goodbye, World!"); msg.run(); }
Java
Interpreter: Java
Library: Swing
import javax.swing.*; public class OutputSwing { public static void main(String[] args) throws Exception { JOptionPane.showMessageDialog (null, "Goodbye, World!"); } }
PHP-Gtk
Interpreter: PHP-Gtk 2.0.0a
if (!class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n"); } $wnd = new GtkWindow(); $wnd->set_title('Goodbye world'); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $lblHello = new GtkLabel("Goodbye, World!"); $wnd->add($lblHello); $wnd->show_all(); Gtk::main();
Python
Interpreter: Python 2.5
Library: Tkinter API (using tkMessageBox helper class)
import tkMessageBox result = tkMessageBox.showinfo("Some Window Label", "Goodbye, World!")
Note: The result is a string of the button that was pressed.
Tcl/tk
Just output as a label in a window:
pack [label .l -text "Goodbye, World"]
Output as text on a button that exits the current application:
pack [button .b -text "Goodbye, World" -command exit]
Visual Basic .NET
Compiler: Visual Basic 2005
Module GoodbyeWorld Sub Main() Messagebox.Show("Goodbye, World!") End Sub End Module