statement type | Pascal | C/Java | comments |
declarations | i, n: integer; type foo20 = array[1..20] of integer; var P: foo20; | int i, n; int P[20]; | Pascal array details not important |
assignment | x := x + 5; | x = x + 5; | beware: C's "=" doesn't mean "equals" ! |
if statement | if i=n then x:=17 else x:=23; | if (i==n) x=17; else x=23; | C condition needs parens, uses == to mean equals |
while loop | while P[i]>=b do i:=i+j; | while (P[i]>=b) i=i+j; | C has no "do" |
grouping | begin x:=4; i:=i+1 end | { x=4; i=i+1; } | insides should be indented |
for loop | for i:=0 to n-1 do begin . . . end | for (i=0; i<n; i=i+1) { . . . } | - |
comments | {a helpful comment} | \\ a helpful comment | - |