C, C++, Python, Java, C#, JavaScript, TypeScript, Pascal, PHP, Bash, Go, Rust, R, Ruby, Lua, Kotlin, Perl, Octave, Julia, Scheme, Dart, Scala, Elixir, Swift, Haskell, MySQL (MariaDB) and HTML / CSS / JS in the browser. Each example below runs live.

C
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 5; i++) {
        printf("%d x %d = %d\n", n, i, n * i);
    }
    return 0;
}
7
C++
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    vector<int> v;
    int x;
    while (cin >> x) {
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    for (int e : v) {
        cout << e << ' ';
    }
    cout << endl;
    return 0;
}
42 7 19 3
Python
n = int(input())
fib = [0, 1]
while len(fib) < n:
    fib.append(fib[-1] + fib[-2])
print(fib)
10
Java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long f = 1;
        for (int i = 2; i <= n; i++) {
            f *= i;
        }
        System.out.println(n + "! = " + f);
    }
}
15
C#
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine($"Max {a.Max()}, average {a.Average():F2}");
    }
}
4 8 15 16 23 42
JavaScript
const line = require('fs').readFileSync(0, 'utf8').trim();
const words = line.split(/\s+/);
console.log(words.reverse().join(' '));
console.log(words.map((w) => w.length));
one two three four
TypeScript
interface Point {
    x: number;
    y: number;
}

const distance = (p: Point, q: Point): number => Math.hypot(p.x - q.x, p.y - q.y);

console.log(distance({x: 0, y: 0}, {x: 3, y: 4}));
Pascal
program Squares;
var
  n, i: integer;
begin
  readln(n);
  for i := 1 to n do
    writeln(i, ' ', i * i);
end.
4
PHP
<?php
$words = explode(' ', trim(fgets(STDIN)));
sort($words);
echo implode(', ', $words), "\n";
pear apple fig plum
Bash
read -r name
for i in 1 2 3; do
    echo "$i. Hello, $name!"
done
Ana
Go
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		fmt.Printf("%d^2 = %d\n", i, i*i)
	}
}
4
Rust
fn main() {
    let nums = vec![2, 4, 6, 8];
    let sum: i32 = nums.iter().sum();
    let doubled: Vec<i32> = nums.iter().map(|x| x * 2).collect();
    println!("Sum = {}", sum);
    println!("Doubled = {:?}", doubled);
}
R
x <- c(4, 8, 15, 16, 23, 42)
cat("mean:", mean(x), "\n")
cat("median:", median(x), "\n")
cat("sd:", round(sd(x), 2), "\n")
Ruby
n = gets.to_i
evens = (1..n).select(&:even?)
puts evens.inspect
puts "Sum: #{evens.sum}"
10
Lua
local t = {5, 3, 8, 1, 9}
table.sort(t)
print(table.concat(t, " "))
print("Count: " .. #t)
Kotlin
fun main() {
    val n = readLine()!!.trim().toInt()
    val primes = (2..n).filter { k -> (2 until k).none { k % it == 0 } }
    println(primes)
}
30
Perl
my %count;
$count{$_}++ for split //, "mississippi";
print "$_: $count{$_}\n" for sort keys %count;
Octave
A = [2 1; 1 3];
b = [3; 5];
x = A \ b;
printf("x = %.1f, y = %.1f\n", x(1), x(2));
Julia
n = parse(Int, readline())
squares = [i^2 for i in 1:n]
println(squares)
println("Sum: ", sum(squares))
6
Scheme
(define (fact n)
  (if (= n 0)
      1
      (* n (fact (- n 1)))))

(display (fact 20))
(newline)
Dart
void main() {
  final names = ['Ana', 'Marko', 'Jovana'];
  for (final name in names) {
    print('${name.toUpperCase()} has ${name.length} letters');
  }
}
Scala
object Main {
  def main(args: Array[String]): Unit = {
    val words = List("scala", "is", "fun")
    println(words.map(_.capitalize).mkString(" "))
    println(words.map(_.length).sum)
  }
}
Elixir
1..5
|> Enum.map(fn x -> x * x end)
|> IO.inspect()
|> Enum.sum()
|> IO.puts()
Swift
let n = Int(readLine()!)!
for i in 1...n {
    print(String(repeating: "*", count: i))
}
4
Haskell
main :: IO ()
main = do
  print (take 10 [x * x | x <- [1 ..]])
  print (sum [1 .. 100])
MySQL (MariaDB)
SELECT author, COUNT(*) AS books, MIN(year) AS first
FROM book
GROUP BY author
ORDER BY first;

CREATE TABLE book (id INT PRIMARY KEY, title VARCHAR(60), author VARCHAR(40), year INT);
INSERT INTO book VALUES
 (1, 'Na Drini cuprija', 'Ivo Andric', 1945),
 (2, 'Prokleta avlija', 'Ivo Andric', 1954),
 (3, 'Dervis i smrt', 'Mesa Selimovic', 1966),
 (4, 'Seobe', 'Milos Crnjanski', 1929),
 (5, 'Tvrdjava', 'Mesa Selimovic', 1970);
HTML / CSS / JS
<h3 id="t">Hello from CodeLab</h3>
<button onclick="document.getElementById('t').style.color = 'crimson'">Colour</button>
<script>
  console.log('Page ready');
</script>
Student
  1. Every language has an example below: click Run, change the code or the input and run it again. Each editor colours the syntax of its language.
  2. Typing help knows the library of the main teaching languages: try in. in Java or Console. in C#.
Teacher
  1. The administrator chooses the languages the site offers (Site administration, Plugins, TinyMCE, CodeLab); only those installed on the runner are offered automatically.
  2. The interface itself is translated into 29 languages.