void main( void )
{
printf("Hello world\n") ;
}
int max(int x, int y) ;
void main(void)
{
printf("max is %d\n", max(x,y));
}
int max(int x, int y)
{
if (x>y)
return( x ) ;
else
return( y ) ;
}
The function definition includes:
return type, name, parameters
body
declarations
instructions
Example:
int max(int x, int y)
{
if (x>y)
return( x ) ;
else
return( y ) ;
}
Example:
int x ;
int y = 0 ;
The declaration of a variable has the following effect:
the compiler is informed that a variable with such name and type has been or will be defined somewhere else
Example:
extern int x ;
Example:
int x ;
long int y ;
unsigned int z ;
signed char x;
range [-128, 127]
The program will produce:
The results is: 10
int x;
scanf("%d", &x ) ;
The program will read a value; this value will be interpreted as integer and stored in variable x.
Escape sequences (special characters) - see also Table 3.1 pag. 61:
\n new line (return)
\t tab (several spaces)
\' single quote
\" double quote
\\ backslash