Programming-Idioms

This language bar is your friend. Select your favorite languages!
S : String := Integer'Image (I);
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
	int a,b, result;
	char opr;
	
	if(argc!=4)
	{
		printf("Invalid arguments...\n");
		return -1;
	}
	
	//get values
	a = atoi(argv[1]);
	b = atoi(argv[3]);
	
	//get operator
	opr=argv[2][0];
	
	//calculate according to operator
	switch(opr)
	{
		case '+':
			result=a+b;
			break;
		case '-':
			result=a-b;
			break;
	}

		printf("%d %c %d = %d\n",a,opr,b,result);
}
(let [s (str i)])
#include <string>
auto s = std::to_string(i);
string s = i.ToString()
import std.conv;
string s = i.to!string;
var s = "$i";
s = Integer.to_string(i)
s = "#{i}"
s = to_string(i)
S = integer_to_list(I).
  write (unit=s,fmt=*) i
import "fmt"
s := fmt.Sprintf("%d", i)
import "strconv"
s := strconv.FormatInt(i, 10)
import "strconv"
s := strconv.Itoa(i)
s = show i
var s = i.toString();
var s = i + "";
String s=((Integer)i).toString();
String s = String.valueOf(i);
String s = "" + i;
String s = Integer.toString(i);
val x = 42.toString()
(setf s (princ-to-string i))
s = tostring(i)
@import Foundation;
NSString *s=@(i).description;
$s = "$i";
$s = (string)$i;
$s = "{$i}";
SysUtils
var
  _s: String;
  _i: Integer;
begin
  _s := IntToStr(_i);
end.
my $s = "" . $i;
$s = "$i";
s = str(i)
s = i.to_s
let s = format!("{}",i);
let s = i.to_string();
val s = i.toString
(define s (number->string i))
Dim myInt As Integer = 12345
Console.WriteLine(myInt.ToString)

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org

Related idioms