Page 26 of 30 FirstFirst ... 162425262728 ... LastLast
Results 251 to 260 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #251
    Join Date
    Jul 2008
    Beans
    1,706

    Re: "Hello Ubuntu" in every programming language

    ignore
    Last edited by jimi_hendrix; January 5th, 2009 at 01:49 AM.

  2. #252
    Join Date
    Mar 2008
    Beans
    323
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: "Hello Ubuntu" in every programming language

    XHTML (With a bit of PHP)

    Code:
    <html>
    <head>
    	<title>Hello World form</title>
    </head>
    <body>
    	<? if(!$_GET['name']){ ?>
    	<form name="input" action="" method="get">
    	What is your name? <input type="text" name="name" />
    	<input type="submit" value="Submit" />
    	</form>
    	<? }else{ ?>
    	Hello,
    	<? echo $_GET['name'];?> 
    	welcome to Ubuntu!
    	<? } ?>
    </body>
    </html>

  3. #253
    Join Date
    Jun 2008
    Location
    Sin City
    Beans
    588
    Distro
    Ubuntu UNR

    Re: "Hello Ubuntu" in every programming language

    Here, lemme fix that for you...
    Quote Originally Posted by sheto View Post
    Python

    Code:
    from os import getlogin
    print ("Hello, " + getlogin() + "! Welcome to Ubuntu")
    There, done.

    (Python <3 understands print("") just as much as Python >3 requires it.
    Warning: Any code examples I write are probably untested and contain bugs. Do not execute directly. Look for intent, not accuracy, please!
    L.A.G. - Jobs Dissembles - 2010/4/29

  4. #254
    -grubby is offline May the Ubuntu Be With You!
    Join Date
    Aug 2007
    Beans
    Hidden!

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Wugglz View Post
    CGI using python

    hellocgi.py

    <snip>
    You could also do it in one file

    helloubuntu.py :

    Code:
    #!/usr/bin/env python
    import cgi
    
    form = cgi.FieldStorage() 
    
    tpl = """
    <html>
    	<head>
    		<title>Hello Ubuntu</title>
    	</head>
    	<body>
    	%s
    	</body>
    </html>
    """
    
    if not form.has_key("submitted") : 
    	form = """
    <p>Hi, what's your name?</p> 
    <form action="helloubuntu.py"> 
        <input type="hidden" name="submitted" value="true" />
        <input type="text" name="name" />
        <input type="submit" value="Get reply" />
    </form>
    """
    	print tpl % form
    else : 
    	print tpl % "Hello, %s! Welcome to Ubuntu!" % form["name"]
    Last edited by -grubby; January 11th, 2009 at 09:27 AM.

  5. #255
    Join Date
    Jul 2007
    Beans
    84
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: "Hello Ubuntu" in every programming language

    <bump>This thread is getting ignored</bump>

  6. #256

    Re: "Hello Ubuntu" in every programming language

    MirthKit

    Code:
    for(;;) {
    text("Hello World! Welcome to Ubuntu.",10,10,100);
    update();
    }
    MirthKit is my game platform project, which runs a language called Squirrel.

    http://www.mirthkit.com
    Last edited by curvedinfinity; January 12th, 2009 at 12:31 AM.
    "Simplicity is the ultimate sophistication." - Leonardo da Vinci

  7. #257
    Join Date
    Jul 2008
    Beans
    1,706

    Re: "Hello Ubuntu" in every programming language

    Erlang:

    Code:
    -module(hello).
    -export([helloUbuntu/2]).
    helloUbuntu() = 
    Name = io:get_line("what is your name? "),
    NewName = string:strip(Name, both, $\n),
    io:format("hello ~s and welcome to ubuntu", [NewName])
    shoudl work but i didnt test...

    you need to run it in an erlang shell though with hello:helloUbuntu after compiling

  8. #258
    Join Date
    Apr 2005
    Location
    Glasgow, Scotland
    Beans
    1,642

    Re: "Hello Ubuntu" in every programming language

    JavaScript, using Seed

    Code:
    Seed.import_namespace("readline");
    Seed.import_namespace("GLib");
    
    var my_name = GLib.get_user_name();
    
    Seed.print("Hello, " + my_name + "! Welcome to Ubuntu");
    Last edited by bruce89; February 18th, 2009 at 02:01 AM.
    A Fedora user

  9. #259
    Join Date
    Nov 2008
    Beans
    9

    Re: "Hello Ubuntu" in every programming language

    posix c

    Code:
    /* written by g3rc4n@gmail.com */
    #include <unistd.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define BUF_SIZE 4096
    
    int main(){
      const char* intro = "Hi! What's your name? ";
      const char* outroa = "\nHello, ";
      const char* outrob = "! Welcome to Ubuntu!\n";
      char* input_buf[BUF_SIZE];
      if(write(STDOUT_FILENO,intro,strlen(intro))==-1)
        exit(EXIT_FAILURE);
      ssize_t n = read(STDIN_FILENO,input_buf,BUF_SIZE-1);
      if(n == -1)
        exit(EXIT_FAILURE);
      if(write(STDOUT_FILENO,outroa,strlen(outroa))==-1)
        exit(EXIT_FAILURE);
      if(write(STDOUT_FILENO,input_buf,n)==-1)
        exit(EXIT_FAILURE);
      if(write(STDOUT_FILENO,outrob,strlen(outrob))==-1)
        exit(EXIT_FAILURE);
      exit(EXIT_SUCCESS);
    }
    policy based c++

    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    
    template<class LANG>
    struct hello_ubuntu : private LANG{
      static void run(std::istream& istr, std::ostream& ostr){
        ostr << LANG::intro();
        std::string name;
        istr >> name;
        ostr << LANG::outroa() << name << LANG::outrob() << std::endl;
      }
    };
    
    struct english{
      static std::string intro(){
        return "Hi! What's your name? ";
      }
      static std::string outroa(){
        return "Hello, ";
      }
      static std::string outrob(){
        return "! Welcome to Ubuntu!";
      }
    };
    
    int main(){
      hello_ubuntu<english>::run(std::cin,std::cout);
      std::exit(EXIT_SUCCESS);
    }
    Last edited by i_heart_pandas; February 18th, 2009 at 02:16 AM.

  10. #260
    Join Date
    Jul 2007
    Beans
    84
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: "Hello Ubuntu" in every programming language

    Started similar thread on Dream In Code, feel fre to move examples. Search for "Hello DIC" on Dream In Code.

Page 26 of 30 FirstFirst ... 162425262728 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •