School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,090 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,039 people online right now. Registration is fast and FREE... Join Now!




"Hello DIC" in every programing language

2 Pages V  1 2 >  

"Hello DIC" in every programing language

krzysz00

27 Feb, 2009 - 04:48 PM
Post #1

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
Here's the deal. Post a program that does these three things:
1. Asks user for his/her name
2. Stores the name in some variable.
3. Print "Hello, " [the user's name, replace with the name] " welcome to DIC" or Dream.In.Code or something to the effect.
ANY programing language and library combination is allowed (i.e. C++, C/Ncurses, Python, Qt). GUI allowed. If you're not sure users wold know, post short instructions on how to compile/run. I'll start with a C++ implementation using the C++ standard library:
CODE
#include<iostream>
#include<string>
using namespace std;

int main()
{
  string a;
  cout << "Type your name: ";
  getline(cin, a);
  cout << "Hello, " << a << ". Welcome to Dream.In.Code\n";
  return 0;
}

Please make sure the code works before posting.

User is offlineProfile CardPM
+Quote Post


Core

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 04:54 PM
Post #2

The .NET Dude
Group Icon

Joined: 8 Dec, 2008
Posts: 3,039



Thanked: 217 times
Dream Kudos: 900
Expert In: C#, VB.NET, WPF, .NET Framework

My Contributions
Moved to Games/Puzzles/Trivia/Jokes. smile.gif
User is online!Profile CardPM
+Quote Post

PsychoCoder

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 05:09 PM
Post #3

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,931



Thanked: 517 times
Dream Kudos: 11550
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Simply place in a C# console application

CODE

public static void Main()
{
    Console.WriteLine("Please enter your name...");
    string name = Console.ReadLine();
    Console.WriteLine("Hello " + name + ", Welcome to Dream.In.Code");
}

User is offlineProfile CardPM
+Quote Post

krzysz00

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 05:38 PM
Post #4

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
Good one PsychoCoder, I'll get this into Mono ('cause I don't use Window$).
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 06:04 PM
Post #5

I exist to Google your problems.
Group Icon

Joined: 23 Aug, 2008
Posts: 5,319



Thanked: 454 times
Dream Kudos: 50
Expert In: Being annoyed with lazy people.

My Contributions
BASH/sh:
bash
#!/usr/bin/env bash

echo -n "Enter your name: "
read name
echo "Hello $name, Welcome to Dream.In.Code"


Python:
python
#!/usr/bin/env python

name = raw_input("Enter your name: ")
print "Hello " + name + ", Welcome to Dream.In.Code"

User is online!Profile CardPM
+Quote Post

AdamSpeight2008

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 06:05 PM
Post #6

The Bandido Coder
Group Icon

Joined: 29 May, 2008
Posts: 2,734



Thanked: 160 times
Dream Kudos: 3925
Expert In: vb.net, LINQ

My Contributions
Console App in VB.Net

CODE

Module Module1
Sub Main()
  Console.WriteLine("Please enter your name...")
  Console.WriteLine("Hello {0} Welcome to Dream.In.Code", Console.ReadLine)
End Sub
End Module

User is online!Profile CardPM
+Quote Post

krzysz00

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 06:40 PM
Post #7

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
Okay, you made me do this...
Common Lisp:
CODE
(defun mk-prompt (string)
  (format *query-io* string)
  (read-line *query-io*)
)
(defvar name (mk-prompt "What's your name: "))
(format t "Hello ~a, welcome to DIC" name)

EAT THAT!

Don't forget you CAN make a GUI or use some library! MORE less well known languages PLEASE!
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: "Hello DIC" In Every Programing Language

27 Feb, 2009 - 09:28 PM
Post #8

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,931



Thanked: 517 times
Dream Kudos: 11550
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Here's a welcome in Haskell

CODE

main = do
   putStrLn "Please enter your name..."
   name <- getLine
   putStrLn ("Hello " ++ name ++ ", Welcome to Dream.In.Code")

User is offlineProfile CardPM
+Quote Post

krzysz00

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 07:21 AM
Post #9

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
Ruby with Qt 4:
CODE
bin/env ruby
require 'Qt4'

include Qt
class Dic < Qt::Widget
  slots 'mesg()'
  def initialize(parent = nil)
    super()
    label = Qt::Label.new(tr('Hi. What\'s your name'), self)
    @text = Qt::LineEdit.new(tr(''), self)
    connect(@text, SIGNAL('returnPressed()'), self, SLOT('mesg()'))
    layout = Qt::VBoxLayout.new()
    layout.addWidget(label)
    layout.addWidget(@text)  
    setLayout(layout)
  end
  def mesg()
    name = @text.text()
    ret = MessageBox::warning(self, "Hi",
    tr("Hi, "+name+". Welcome to Dream.In.Code!"),
    MessageBox::Ok | MessageBox::Cancel,
    MessageBox::Ok)
    $qApp::quit()
  end
end

app = Qt::Application.new(ARGV)

widget = Dic.new()
widget.setWindowTitle(Qt::Widget::tr("Hello DIC"))
widget.show()

app.exec()

First GUI app posted.
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 07:58 AM
Post #10

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,931



Thanked: 517 times
Dream Kudos: 11550
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Perl
CODE

#Hello World in Perl
#Get the users name
#input
print "Please enter your name...";
$name = <STDIN>;
#output
print "Hello "
print $name;
print ", Welcome to Dream.In.Code\n";

User is offlineProfile CardPM
+Quote Post

ayman_mastermind

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 10:33 AM
Post #11

human.setType("geek");
Group Icon

Joined: 12 Dec, 2008
Posts: 1,809



Thanked: 92 times
Dream Kudos: 525
My Contributions
In Java! smile.gif
CODE

import java.util.Scanner;
public class Welcome {
    public static void main(String[] args){
        Scanner Input = new Scanner(System.in);
        System.out.println("Please enter your name: ");
        String name = Input.next();
        System.out.println("Hello " + name + " Welcome to Dream.In.Code!");
    }
}

btw, happy birthday to Dream.In.Code and greetings to all members of this helpful and warm community! wink2.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 10:53 AM
Post #12

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,931



Thanked: 517 times
Dream Kudos: 11550
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
BASIC
CODE

10 name As String
20 Input "Please enter your name...", name
30 Print
40 Print "Hello "; name; ", Welcome to Dream.In.Code"
50 Sleep
60 End

User is offlineProfile CardPM
+Quote Post

krzysz00

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 11:18 AM
Post #13

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
When I finish the RPN calculator I'm working on, I'm taking a crack as gas assembler. C'mon, beat me to it!!
User is offlineProfile CardPM
+Quote Post

krzysz00

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 03:19 PM
Post #14

D.I.C Head
Group Icon

Joined: 25 Feb, 2009
Posts: 78



Thanked: 2 times
Dream Kudos: 100
My Contributions
QUOTE(ayman_mastermind @ 28 Feb, 2009 - 11:33 AM) *

In Java! smile.gif
CODE

import java.util.Scanner;
public class Welcome {
    public static void main(String[] args){
        Scanner Input = new Scanner(System.in);
        System.out.println("Please enter your name: ");
        String name = Input.next();
        System.out.println("Hello " + name + " Welcome to Dream.In.Code!");
    }
}

btw, happy birthday to Dream.In.Code and greetings to all members of this helpful and warm community! wink2.gif

My Java one is shorter than yours
CODE
import java.io.Console;
public class dic
{
    public static void main(String args[])
    {
    Console dream = new System.console();
    String line = dream.readLine("Type your name: ");
    echo.printf("You typed %s.%n", line);
    }
}


This post has been edited by krzysz00: 28 Feb, 2009 - 04:33 PM
User is offlineProfile CardPM
+Quote Post

ericr2427

RE: "Hello DIC" In Every Programing Language

28 Feb, 2009 - 06:59 PM
Post #15

D.I.C Regular
Group Icon

Joined: 1 Dec, 2008
Posts: 292



Thanked: 21 times
Dream Kudos: 150
My Contributions
PHP! Pretty much the worst language to do this in...
CODE

<?php
if (isset($POST['submit'])) {
  echo "Hello, ".$_POST['name'].", welcome to DIC!";
}
else {
  echo '<form action="'.$_SERVER[php_self].'" method="post">
           <h3>Type your name: </h3>
           <input type="text" name="name" size="25">
           <input type="submit" name="submit">
           </form>';
}
?>

User is offlineProfile CardPM
+Quote Post

computerfox

RE: "Hello DIC" In Every Programing Language

1 Mar, 2009 - 12:14 PM
Post #16

straight vegetarian kid
*****

Joined: 29 Jan, 2009
Posts: 3,772



Thanked: 48 times
Dream Kudos: 1700
My Contributions
CODE


#include<iostream>
#include<string>
using namespace std;

void helloWorld(string a);
int main()
{
     string name;

     cout<<"Please enter name: ";
     cin>>name;

     helloWorld(name);

     return 0;
}

void helloWorld(string a)
{
     cout<<"\n welcome to the DIC family "<<a<<"\n";

     return;
}



This post has been edited by computerfox: 1 Mar, 2009 - 12:15 PM
User is offlineProfile CardPM
+Quote Post

no2pencil

RE: "Hello DIC" In Every Programing Language

1 Mar, 2009 - 08:18 PM
Post #17

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,492



Thanked: 303 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
Korn Shell :

CODE

#!/bin/ksh

read name?"Type your name: "

echo "Hello, ${name}. Welcome to Dream.In.Code"


C
CODE

#include <stdio.h>

int main(void) {
  char _name[256];
  printf("Type your name: ");
  scanf("%s",_name);
  printf("Hello, %s. Welcome to Dream.In.Code\n",_name);

  return 0;
}


JavaScript
CODE

<html><head>
<script language="JavaScript">
<!--    
function hello(Name) {
    alert("Hello " + Name.value + ". Welcome to Dream.In.Code");
}
-->
</script>
</head>
<body>
<form>
Type your name: <input id="_name" type=text name="_name" value=""><br>
<input class="submit" type="button" onclick="hello(_name)" value="Submit">
</form></body></html>

User is online!Profile CardPM
+Quote Post

OliveOyl3471

RE: "Hello DIC" In Every Programing Language

1 Mar, 2009 - 08:52 PM
Post #18

Quick and Dirty
Group Icon

Joined: 11 Jul, 2007
Posts: 5,659



Thanked: 107 times
Dream Kudos: 775
Expert In: Basketball

My Contributions
Guess

CODE
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello World</title>
<meta http-equiv = "content-type" content = "text/html; charset = iso-8859-1" />

</head>
<body>
<script type="text/javascript">
var name=(prompt("Enter name: ",""));
    /* <![CDATA[ */
document.write("<p><h3>Hello " + name + " . Welcome to Dream In Code, where all your wildest dreams come true!</h3></p>");
    /* ]]> */
</script>
</body>
</html>


tongue.gif
User is online!Profile CardPM
+Quote Post

PsychoCoder

RE: "Hello DIC" In Every Programing Language

2 Mar, 2009 - 11:05 PM
Post #19

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,931



Thanked: 517 times
Dream Kudos: 11550
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
LOLCODE

CODE

HAI
   CAN HAS STDIO?
   I HAS A YERNAME
   VISIBLE "Please enter your name..."
   GIMMEH LINE YERNAME
   VISIBLE "Hello "!
   VISIBLE YERNAME!
   VISIBLE ", Welcome to Dream.In.Code"
KTHXBYE

User is offlineProfile CardPM
+Quote Post

5thWall

RE: "Hello DIC" In Every Programing Language

3 Mar, 2009 - 12:07 AM
Post #20

D.I.C Regular
Group Icon

Joined: 17 Sep, 2008
Posts: 298



Thanked: 9 times
My Contributions
Slag (see my sig)

CODE

[mainClass hello]

class hello
  METHODS
    method init:
      local var name = input_String( "What is your name?\n" )
      println( "Hello $. Welcome to Dream In Code" (name) )
endClass


This post has been edited by 5thWall: 3 Mar, 2009 - 12:14 AM
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 11:28AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month