Below you will find a sample program for every language available on Ideone. Click fork to execute the code.
- go to:
- Ada95
- Assembler 32bit (gcc)
- Assembler 32bit (nasm)
- Assembler 64bit
- AWK (gawk)
- AWK (mawk)
- Bash
- BC
- Brainf**k
- C
- C (clang)
- C#
- C# (Mono)
- C++
- C++ 4.3.2
- C++17 (clang)
- C++23
- C99
- Clips
- Clojure
- Cobol
- COBOL 85
- CoffeeScript
- Common Lisp (CLISP)
- Common Lisp (SBCL)
- D (dmd)
- D (gdc)
- D (ldc)
- Dart
- Elixir
- Erlang
- F#
- F# (.NET)
- Fantom
- Forth
- Fortran
- Go
- Gosu
- Groovy
- Haskell
- Icon
- Intercal
- Java
- Java 12
- JavaScript (Rhino)
- JavaScript (SpiderMonkey)
- Julia
- Kotlin
- Lean
- Lua
- Nemerle
- Nice
- Nim
- Node.js
- Objective-C
- Objective-C (clang)
- OCaml
- Octave
- Pascal
- Pascal (gpc)
- Perl
- Perl 6
- PHP
- Pico Lisp
- Pike
- Prolog
- Prolog (GNU)
- Python 2
- Python 2 (PyPy)
- Python 3
- Python 3 (PyPy)
- Python 3 ML/AI
- R
- Racket
- Ruby
- Rust
- Scala
- Scheme (Chicken)
- Scheme (Guile)
- Scheme (Stalin)
- Smalltalk
- SQLite
- Swift
- TCL
- Text
- TypeScript
- Unlambda
- VB.NET (Mono 3.10)
- VB.NET (Mono 4.7)
- Whitespace
- Zig
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;
.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 # }
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
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: 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
#!/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; }
#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.
fs = require 'fs' for line in fs.readFileSync(0, 'utf8').split /\r?\n/ trimmed = line.trim() continue if trimmed is '' n = parseInt trimmed, 10 break if n is 42 console.log n
import std.stdio; int main() { int x; while (scanf("%d", &x) && x!=42) printf ("%d\n", x); return 0; }
import std.stdio; int main() { int x; while (scanf("%d", &x) && x!=42) printf ("%d\n", x); return 0; }
import std.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(); if( input != null){ 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")
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); } }
while((num = readline()) != 42) { print(num); }
function main() for line in eachline(stdin) s = strip(line) isempty(s) && continue n = parse(Int, s) n == 42 && break println(n) end end main()
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); } }
def main : IO Unit := do let stdin ← IO.getStdin repeat let line ← stdin.getLine if line.isEmpty then break match line.trimAscii.copy.toInt? with | some 42 => break | some n => IO.println n | none => pure ()
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
using System; public class Test { public static Main() : void { def a = Console.Read() - 48; def _nl = Console.Read(); def b = Console.Read() - 48; Console.WriteLine(a + b); } }
{ 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:byte; begin readln(x); while x<>42 do begin writeln(x); readln(x) end end.
program ideone; var x: integer; begin repeat readln(x); if x<>42 then writeln(x); until x=42 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())
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)
from sys import stdin for line in stdin: n = int(line) if n == 42: break print(n)
import sys import tensorflow as tf @tf.function(autograph=False) def filter_until_42(raw_text: tf.Tensor): tokens = tf.strings.split(raw_text) nums = tf.strings.to_number(tokens, out_type=tf.int32) is_42 = tf.cast(tf.equal(nums, 42), tf.int32) mask = tf.equal(tf.math.cumsum(is_42), 0) result = tf.boolean_mask(nums, mask) return tf.strings.reduce_join(tf.strings.as_string(result), separator="\n") raw = tf.constant(sys.stdin.read(), dtype=tf.string) out = filter_until_42(raw).numpy().decode() if out: print(out)
f <- file("stdin") open(f) while(length(n <- as.integer(readLines(f,n=1))) > 0) { if (n == 42) { break; } write(n, stdout()) }
#lang racket (let loop () (define x (read)) (unless (or (eof-object? x) (equal? x 42)) (displayln x) (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 } } }
(let loop ((number (read))) (if (= number 42) (exit) (begin (print number) (loop (read)))))
(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* ((a (read)) (b (read))) (write (+ a b)) (newline))
|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] }
Traceback (most recent call last): File "./prog.py", line 8, in <module> AttributeError: 'str' object has no attribute 'product'
```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
const std = @import("std"); pub fn main(init: std.process.Init) !void { var stdin_buf: [1024]u8 = undefined; var stdin_reader = std.Io.File.stdin().reader(init.io, &stdin_buf); const stdin = &stdin_reader.interface; var stdout_buf: [1024]u8 = undefined; var stdout_writer = std.Io.File.stdout().writer(init.io, &stdout_buf); const stdout = &stdout_writer.interface; while (try stdin.takeDelimiter('\n')) |raw_line| { const line = std.mem.trim(u8, raw_line, " \r\t"); if (line.len == 0) continue; const n = try std.fmt.parseInt(i64, line, 10); if (n == 42) break; try stdout.print("{d}\n", .{n}); } try stdout.flush(); }