procedure jim(joe : integer ; x, y : character)
{ procedure header, declares a procedure with
three parameters of the specified types }
const
MAX = 23; { local constant declaration }
var
henry : integer; { local integer variable declaration }
begin
henry := joe;
jim(henry, 'a', 'b') { procedure call }
end; void jim( int joe, char x, char y ) {
/* Jim is a function that returns no value,
as indicated by void, but has three parameters
with the indicated types, notice the type
names have been shortened */
const int MAX = 23; /* One way to define a constant */
int henry; /* local integer variable declaration */
/* All variable declarations must immediately
follow a {, after that, code can start */
henry = joe;
jim(henry, 'a', 'b');
}From the C style guide available from the University of Washington
type pdp11 VAX/11 68000 Cray-2 Unisys Harris 80386
series family 1100 H800
___________________________________________________________________
char 8 8 8 8 9 8 8
short 16 16 8/16 64(32) 18 24 8/16
int 16 32 16/32 64(32) 36 24 16/32
long 32 32 32 64 36 48 32
char* 16 32 32 64 72 24 16/32/48
int* 16 32 32 64(24) 72 24 16/32/48
int(*)() 16 32 32 64 576 24 16/32/48
Some machines have more than one possible size for a
given type. The size you get can depend both on the
compiler and on various compile-time flags. The fol-
lowing table shows ``safe'' type sizes on the majority
of systems. Unsigned numbers are the same bit size as
signed numbers.
Type Minimum No Smaller
# Bits Than
_____________________________
char 8
short 16 char
int 16 short
long 32 int
float 24
double 38 float
any * 14
char * 15 any *
void * 15 any *
for (...) {
+--------------+
|statement\_1; |
|statement\_2; |
|... |
|statement\_n; |
+--------------+
} for (...) {
+----------------+
|for (...) { |
| +-----------+ |
| |if (...) { | |
| | +------+ | |
| | |... | | |
| | +------+ | |
| | } | |
| +-----------+ |
| } |
| ... |
+----------------+
} for (...) {
int i;
...
} void foo() {
int i; /* local variables */
...
}
void main() { /* main known as a function in remainder of program */
int henry; /* local variable henry, only known within main() block */
void alice(); /* forward reference to alice() function, needed
because alice has yet to be defined */
henry = alice(); /* call to alice() */
}
int alice() { /* alice known as a function in remainder of program */
int jill; /* local variable jill, only known in alice() */
jill = 32;
return (jill);
}
void june() { /* june known as a function in remainder of program */
printf("%d", alice()); /* alice defined above, so name is known here */
}
The above example puts main, alice, and june into the
global name space.