• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Fun activity Say hello... in a coding language!

Nous

New Coder
C++:
#include <iostream>
using namespace std;

int main() {
    cout << "Hello World" << endl;
    return 0;
}

:alien:
 

Ghost

Active Coder
I wrote a function that can take a command "s" and interpret anything after it as an echo.
It could obviously be expanded to allow other shorthand code...

[CODE lang="php" title="fakephp code sample (echo shorthand for php)"]<?php

function fakephp($string){
$endofline = "<br>"; // use PHP_EOL for console / server outputs
//echo "the string is".$string;
$lines = explode( "\n",$string);
//print_r($lines);
$linemax = count($lines);
$linecount = 0;
foreach($lines as $line){
if(strpos($line, "s ") === 0){
$sayvalue = str_replace("s ", "", $line);
$endsay = $linecount < $linemax-1 ? $endofline : "";
echo $sayvalue . $endsay;
}
$linecount++;
}
}

$code = "s Hello!
s How are you?";

fakephp($code);

?>[/CODE]

This was kind of fun to write, so I actually expanded upon this idea and started a github project:

I use a class file (FakePHP.php) and you can run the code by using index.php

I will add other commands to it in the future, but for now it just handles echos, linebreaks, and simple strings.

I also included the ability to send code blocks in an array so that multiple bits of code can be processed in one "run" function.
 
Last edited:

Ash

Active Coder
C++:
#include <iostream>


using namespace std;

int main() {

cout << "Hello everyone";

return 0;

}
 

Ghost

Active Coder
HTML:
<span>Hello Ash!</span>
Code:
C     Fortran

      PROGRAM HELLO
      WRITE (*,100)
      STOP
  100 FORMAT (' Hello Malcolm! ' /)
      END
~ courtesy of: http://helloworldcollection.de/#Fortran

The hello world collection is pretty cool. They currently have 603 versions of Hello World, all different programming languages, and 78 human languages supported too.

Fortran is the oldest programming language (still in use), according to many.

There's a lot of cool things on this site. For example, here's a language that's used for the Medal of Honor game:
Code:
// Hello World in the Medal of Honor Allied Assault scripting language

iprintln "Hello World!"
 

Arthur

New Coder
C:
#include <stdio.h>

int main () {
   int message[] = {72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33};
   int limit = sizeof (message) / sizeof (message[0]);
   int loop;
   for (loop = 0; loop < limit; loop++) {
      printf("%c", message[loop]);
   }
   printf("\n");
  
   return 0;
}
 

Ghost

Active Coder
C:
#include <stdio.h>

int main () {
   int message[] = {72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33};
   int limit = sizeof (message) / sizeof (message[0]);
   int loop;
   for (loop = 0; loop < limit; loop++) {
      printf("%c", message[loop]);
   }
   printf("\n");
 
   return 0;
}

Code:
yourname = input("What is your name? [ Type in & press ENTER KEY ]\n")
if yourname and len(yourname) > 0:
    print("Hello " + yourname)
else:
    print("Hey you!")
 

Top