ANSI C Turbo Pascal FreeBASIC XPL0 ---------------------- ---------------------- ---------------------- ---------------------- + - * All four languages use these fundamental arithmetic operators. / div (integer) / (real) / / % mod Mod Rem(Y/3); rem(0); << >> (signed) shl shr Shl Shr (signed) << >> ->> (signed) > >= < <= All use these comparison symbols. == = = = != <> <> # ~ ! not Not ~ not & && and And & and | || or Or ! or ^ - xor Xor | xor (...) All use parentheses in expressions and for passing arguments to subroutines. #include program Fac; uses Crt; include c:\cxpl\codes; int main() { var N0, N, F: integer; dim as integer N0, N, F int N0, N, F; int n0, n, f; begin begin scanf("%d", &n0); Read(N0); input N0 N0:= IntIn(0); f = 2; n = n0; F:= 2; N:= N0; F = 2 : N = N0 F:= 2; N:= N0; do /* show factors */ repeat {show factors} do 'show factors repeat \show factors if (n%f == 0) if N mod F = 0 then if N mod F = 0 then if Rem(N/F) = 0 then { begin if N <> N0 then begin if (n != n0) if N <> N0 then print "*"; if N # N0 then putchar('*'); Write('*'); end if ChOut(0, ^*); printf("%d", f); Write(F); print F; IntOut(0, F); n = n/f; N:= N div F; N = N/F N:= N/F; } end else end else f++; else Inc(F); F = F+1 else F:= F+1; while (f <= n); until F > N; end if until F > N; if (f == n0) if F = N0 then loop until F > N if F = N0 then printf(" is prime"); Write(' is prime'); if F = N0 then Text(0, " is prime"); printf("\n"); Writeln; print " is prime"; CrLf(0); return 0; } end. end if : print end; _NAME2 != _name2 _NAME2 = _name2 _NAME2 = _name2 _NAME2 = _Name2 double x,y,z; var x,y,z: Double; Dim As Double x,y,z real X,Y,Z; char str[10]; var Str: array [0..9] Dim str (0 To 9) char Str(10), Tbl; of char; As UByte Tbl:= Reserve(20); #define K 20 const k=20; Pi=3.14; #define K 20 def K=20, Pi=3.14; const double PI=3.14; Const As Double pi=3.14 void wait(void) procedure wait; Sub wait proc Wait; End Sub double d2r(double d) function D2R(D:double): Function D2R(d As func real D2R(D); { double; begin Double) As Double real D; return d*PI/180; D2R := D*Pi/180; Return d*pi/180 return D*Pi/180.; } end; End Function wait(); wait; wait Wait; x=d2r(30); x := D2R(30); x = D2R(30) X:= D2R(30.0); 0xA3e5 $A3e5 &hA3e5 &B01101 $A3e5 %01101 1 0 True False (= 1, 0) 1 0 true false (= -1, 0) &i addr(i) @i @i addr I z = (x==20) ? 25 : 30; if x=20 then z:= 25 If x=20 Then z=25 Z:= if X=20 then 25 else z:= 30; Else z=30 else 30; End If switch (i) { case I of Select Case i case I of case 1: x=1; break; 1: X:=1; Case 1 x=1 1: X:=1; case 2: x=2; break; 2: X:=2; Case j x=2 J: X:=2 default: x=0; else X:=0; Case Else x=0 other X:=0; } end; End Select while (I<10) while I<10 do While i<10 while I<10 do I++; Inc(I); i=i+1 I:=I+1; Wend for (i=0; i<=10; i++) for i := 0 to 10 do For i=0 To 10 for I:= 0 to 10 do x+=i; x := x+i; x=x+I X:=X+I; Next i for (i=10; i>=0; i--) for i:= 10 downto 0 do For i=10 Downto 0 for I:= 10 downto 0 do x+=i; x:= x+i; x=x+i X:= X+I; for(;;) while true do Do loop if x==10 then break; if x=10 then break If x=10 Then Exit Do if X=10 then quit; continue; continue Continue -- exit(0); halt Stop n exit N; label L210; goto L210; goto L210; Goto L210 -- L210: L210: L210: printf("%11.5lf",x); write(x:11:5); Print Using "##.##"; x Format(5,5); RlOut(0,X); printf("%X",i); -- Print Hex(i,8); HexOut(0,I); printf("I'm %d\n",i); writeln('I''m ',i); Print "I'm "; i Text(0,"I'm "); IntOut(0,I); CrLf(0); c=getchar(); c := ReadKey; Input c C:= ChIn(0); scanf("%lf",&x); read(x); Input x X:= RlIn(0); abs(i); fabs(x); Abs(x); Abs(x) Abs(I); RlAbs(X); abs(X) i=rand()%10; i:=Random(10); i=Rnd*10 I:=Ran(10); printf("\x1b[%d;%dH",y,x); GotoXY(1,1); Locate 1,1 Cursor(0,0); sqrt sin acos atan2 Sqrt Sin -- ArcTan Sqr Sin Acos Atan2 Sqrt Sin ACos ATan2 SoftInt i = y; i := round(y); i = CInt(y) I:= Fix(Y); y = i; y := i; Y:= Float(I); x[5] = y[6]; x[5] := y[6]; x(5) = y(6) X(5):= Y(6); x[i][j] x[i,j] x(i,j) X(I,J) int rpm[]={33,45,78}; const RPM: array[0..2] Dim RPM(0 To 2) As int RPM; of integer=(33,45,78); Integer => {33,45,78} RPM:= [33,45,78]; struct coord type Coord = record type Coord real Vel_X,Vel_Y,Vel_Z; { double x, y, z; X, Y, Z: double; x as double real Pos_X,Pos_Y,Pos_Z; }; end; z as double struct coord vel, pos; var Vel, Pos: Coord; end type vel.x = 44.5; Vel.X:= 44.5; dim Vel as Coord Vel_X:= 44.5; pos.z = 10.8; Pos.Z:= 10.8; Vel.x = 44.5 Pos_Z:= 10.8; Data Types Bytes -- 1 Boolean -- -- char 1 Shortint Byte -- int, short 2 Integer Short int (16-bit version) long 4 Longint, LongBool Integer, Long int (32-bit version) unsigned char 1 Char, Byte UByte char (array) unsigned int 2 Word, WordBool UShort -- unsigned long 4 Pointer UInteger, ULong -- -- 8 -- LongInt -- -- 6 Real -- -- -- 8 -- ULongInt -- float 4 Single Single short (segments) double 8 Double Double real -- 10 Extended -- -- -- 8 Comp -- -- Last update: 3-Jan-2012