Below you will find a sample program for every language available on Ideone. Click fork to execute the code.
- go to:
- Ada95
- Assembler 32bit
- Assembler 32bit
- AWK
- AWK
- Bash
- BC
- Brainf**k
- C
- C#
- C#
- C++
- C++ 4.3.2
- C++14
- C99
- Clips
- Clojure
- Cobol
- COBOL 85
- Common Lisp
- Common Lisp
- D
- D
- Dart
- Elixir
- Erlang
- F#
- Fantom
- Forth
- Fortran
- Go
- Gosu
- Groovy
- Haskell
- Icon
- Intercal
- Java
- Java
- JavaScript
- JavaScript
- Kotlin
- Lua
- Nemerle
- Nice
- Nim
- Node.js
- Objective-C
- Objective-C
- OCaml
- Octave
- Pascal
- Pascal
- Perl
- Perl
- PHP
- Pico Lisp
- Pike
- Prolog
- Prolog
- Python
- Python 3
- R
- Racket
- Ruby
- Rust
- Scala
- Scheme
- Scheme
- Scheme
- Smalltalk
- SQLite
- Swift
- TCL
- Text
- Unlambda
- VB.NET
- VB.net
- Whitespace
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Test is subtype Small is Integer range 0..99; Input : Small; begin loop Get(Input); if Input = 42 then exit; else Put (Input); New_Line; end if; end loop; end;
global _start section .data buffer dw 0h section .text _start: mov ecx, buffer mov edx, 02h call read mov cx, word [buffer] cmp cx, 3234h je exit cmp ch, 0ah je one_dig jmp two_dig one_dig: mov ecx, buffer mov edx, 02h call write jmp _start two_dig: mov ecx, buffer mov edx, 02h call write mov edx, 01h mov ecx, buffer call read ; read the 0ah mov ecx, buffer call write ; write the 0ah jmp _start exit: mov eax, 01h ; exit() xor ebx, ebx ; errno int 80h read: mov eax, 03h ; read() mov ebx, 00h ; stdin int 80h ret write: mov eax, 04h ; write() mov ebx, 01h ; stdout int 80h ret
.data x: .long 0 s: .string "%d\n\0" .text .global main main: # int main() # { loop: # for (;;) { pushl $x # scanf("%d", &x); pushl $s call scanf addl $8, %esp movl x, %eax # if (x == 42) break; subl $42, %eax jz break pushl x # printf("%d\n", x); pushl $s call printf addl $8, %esp jmp loop # } break: xor %eax, %eax # return 0; ret # }
#!/bin/bash while true do read line if [ $line -eq 42 ] then exit 0 fi echo $line done
while (1 == 1) { x = read(); if (x != 42) { print x, "\n"; } else { break; } }
>+[>>,----------[>,----------]+++++[<-------->-]<[>>-<]>+[ -<+++++++[<------>-]<[>>-<]>+[ -<<[>>-<]>+[<<->>->]> ]<+++++++[<++++++>-]>> ]<++++++++[<+++++>-]< [<]<[>>[++++++++++.>]++++++++++.[[-]<]]<]
using System; public class Test { public static void Main() { int n; while ((n = int.Parse(Console.ReadLine()))!=42) Console.WriteLine(n); } }
using System; public class Test { public static void Main() { int n; while ((n = int.Parse(Console.ReadLine()))!=42) Console.WriteLine(n); } }
#include <iostream> using namespace std; // consider removing this line in serious projects int main() { int intNum = 0; cin >> intNum; while (intNum != 42) { cout << intNum << "\n"; cin >> intNum; } return 0; }
#include <iostream> using namespace std; // consider removing this line in serious projects int main() { int intNum = 0; cin >> intNum; while (intNum != 42) { cout << intNum << "\n"; cin >> intNum; } return 0; }
#include <iostream> using namespace std; // consider removing this line in serious projects int main() { auto func = [] () { int intNum = 0; cin >> intNum; while (intNum != 42) { cout << intNum << "\n"; cin >> intNum; } }; func(); return 0; }
(defrule readin ?f<-(initial-fact) => (retract ?f) (assert (number (read))) ) (defrule writeout ?f<-(number ?n)(test (<> ?n 42)) => (retract ?f) (printout t ?n crlf) (assert (initial-fact)) ) (reset) (run) (exit) ; empty line at the end
(loop [num (read-line)] (if (= num "42") '() (do (println num) (recur (read-line)))) )
IDENTIFICATION DIVISION. PROGRAM-ID. IDEONE. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 n PIC Z9 . PROCEDURE DIVISION. ACCEPT n PERFORM UNTIL n = 42 DISPLAY n ACCEPT n END-PERFORM. STOP RUN.
IDENTIFICATION DIVISION. PROGRAM-ID. IDEONE. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 77 n PIC Z9 . PROCEDURE DIVISION. ACCEPT n PERFORM UNTIL n = 42 DISPLAY n ACCEPT n END-PERFORM. STOP RUN.
(loop for line = (read-line *standard-input* nil nil) while (not (equal line "42")) do (format t "~A~%" line))
import std.c.stdio; int main() { int x; while (scanf("%d", &x) && x!=42) printf ("%d\n", x); return 0; }
import 'dart:io'; void main() { while(true) { String input = stdin.readLineSync(); var n = int.parse(input); if (n == 42) { break; } print(n); } }
seq { while true do yield stdin.ReadLine () } |> Seq.takeWhile ((<>) "42") |> Seq.iter (printfn "%s")
class FantomSay { Void main(Str[] args) { while (true) { str := Env.cur.in.readLine n := Int.fromStr (str, 10, false) if (n == 42) { break; } echo(n) } } }
create inbuf 16 chars allot : gobble begin key dup 48 < while drop repeat ; : readint dup gobble begin dup 47 > while over c! 1+ key repeat drop over - ; : kthx begin inbuf readint over over s" 42" compare while type cr repeat drop drop ; kthx bye
program TEST integer ans do read (*,*) ans if (ans.eq.42) stop write (*,*) ans enddo stop end
package main import "fmt" func main(){ var n int fmt.Scanf("%d",&n) for n!=42 { fmt.Printf("%d\n",n) fmt.Scanf("%d",&n) } }
uses java.io.InputStreamReader uses java.util.Scanner uses java.lang.System var scanner = new Scanner( new InputStreamReader( System.in ) ) while (true) { var n = scanner.nextInt() if (n == 42) { break; } print( n ) }
class Ideone { static void main(String[] args) { for (line in System.in.readLines()) { if (line != "42") { println(line); } else { break; } } } }
PLEASE DO ,1 <- #1 PLEASE DO .4 <- #0 PLEASE DO .5 <- #0 PLEASE DO .99 <- #0 DO COME FROM (30) DO COME FROM (31) DO WRITE IN ,1 DO .1 <- ,1SUB#1 DO .2 <- .4 DO (1000) NEXT DO .4 <- .3~#255 DO (10) NEXT (42) DO .1 <- .1 (20) DO .42 <- "&'&.4~#26'$#1" PLEASE RESUME "?.42$#1"~#3 (10) DO (20) NEXT DO FORGET #1 PLEASE COME FROM (42) PLEASE STASH .1+.2+.3 DO .1 <- .4 DO .2 <- #50 DO (1010) NEXT DO (100) NEXT PLEASE STASH .1+.2+.3 DO .1 <- .99 DO .2 <- #52 DO (1010) NEXT DO (101) NEXT PLEASE GIVE UP (201) DO .3 <- '.3~.3'~#1 PLEASE RESUME "?.3$#2"~#3 (101) DO (201) NEXT DO FORGET #1 (32) PLEASE RETRIEVE .1+.2+.3 (200) DO .3 <- '.3~.3'~#1 PLEASE RESUME "?.3$#2"~#3 (100) DO (200) NEXT DO FORGET #1 DO COME FROM (32) PLEASE RETRIEVE .1+.2+.3 DO (102) NEXT (31) DO .99 <- .4 (202) DO .98 <- '.99~.99'~#1 PLEASE RESUME "?.98$#2"~#3 (102) DO (202) NEXT DO FORGET #1 DO .3 <- !99~#15'$!99~#240' DO .3 <- !3~#15'$!3~#240' DO .2 <- !3~#15'$!3~#240' DO .1 <- .5 DO (1010) NEXT DO .5 <- .2 DO ,1SUB#1 <- .3 PLEASE READ OUT ,1 (30) DO .99 <- .4
/* package whatever; // don't place package name! */ import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { String s; } }
/* package whatever; // don't place package name! */ import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { String s; } }
importPackage(java.io); importPackage(java.lang); var reader = new BufferedReader( new InputStreamReader(System['in']) ); while(true) { var line = reader.readLine(); if(line == null || line == "42") { break; } else { System.out.println(line); } }
import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) while (true) { val input: String = sc.next() if (input.trim().toLowerCase() == "42") { break } println(input); } }
local read, write = io.read, io.write local num, nl = '*n', '\n' while true do local a = read(num) if a == 42 then return end write(a, nl) end
{ String s; }
import os import strutils while true: var line:string = stdin.readLine x = line.parseInt if x == 42: break else: echo line
process.stdin.resume(); process.stdin.setEncoding('utf8'); var remainder = '' process.stdin.on('data', function (chunk) { var lines = chunk.toString().split('\n'); lines.unshift(remainder + lines.shift()); remainder = lines.pop(); lines.forEach(function(line) { if (line === '42') { process.exit(); } process.stdout.write(line+'\n'); }); });
while true do print_int n; done;
program ideone; var x: integer; begin repeat readln(x); if x<>42 then writeln(x); until x=42 end.
program ideone; var x:byte; begin readln(x); while x<>42 do begin writeln(x); readln(x) end end.
(in NIL (loop (setq N (format (read))) (T (= "42" N)) (prinl N)) )
printl_list([H|X]):- put_code(H), printl_list(X). read_line_codes(A, L) :- get_code(C), ( C == -1 -> ( A == [] -> L = end_of_file ) ; ( C == 0'\n -> reverse(A, L) ; read_line_codes([C|A], L) ) ). :- initialization(main). main :- repeat, read_line_codes([], X), (X == [52,50] -> ( halt ) ; ( nl, printl_list(X) )), X == end_of_file, halt.
n = int(raw_input()) while n != 42: print n n = int(raw_input())
from sys import stdin for line in stdin: n = int(line) if n == 42: break print(n)
f <- file("stdin") open(f) while(length(n <- as.integer(readLines(f,n=1))) > 0) { if (n == 42) { break; } write(n, stdout()) }
(let loop () (let/ec break (define a (read)) (when (= a 42) (break)) (writeln a) (loop)))
use std::io::stdin; use std::io::BufRead; use std::io::BufReader; fn main() { for line in BufReader::new(stdin()).lines() { match line { Ok(ref s) if s == "42" => break, Ok(ref s) => println!("{}", s), _ => continue } } }
(define (do_it n) (define (print_it n) (display n) (newline)) (cond ((not(= n 42)) (print_it n) (do_it (read))) )) (do_it (read))
(let loop ((number (read))) (if (= number 42) (exit) (begin (print number) (loop (read)))))
|c number| [ number:=0. [ (c := stdin next) asciiValue ~= 10 ] whileTrue: [number := (number * 10) + (c asciiValue) - 48.]. number ~= 42 ] whileTrue: [Transcript show: number printString; cr.] !
create table tbl(str varchar(20)); insert into tbl values('Hello world!'); select * from tbl;
while let line = readLine() { let n = Int(line) if n == 42 { break } print(n!) }
set num [gets stdin] while { $num != 42 } { puts $num; set num [gets stdin] }
```s``sii`ki ``s``s`ks ``s``s`ks``s`k`s`kr ``s`k`si``s`k`s`k `d````````````.H.e.l.l.o.,. .w.o.r.l.d.! k k `k``s``s`ksk`k.*
Imports System Public Class Test Public Shared Sub Main() Dim n As Integer n = Console.ReadLine Do While n <> 42 System.Console.WriteLine(n) n = Console.ReadLine Loop End Sub End Class
Imports System Public Class Test Public Shared Sub Main() Dim n As Integer n = Console.ReadLine Do While n <> 42 System.Console.WriteLine(n) n = Console.ReadLine Loop End Sub End Class