Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
*********************************************
The C Programming Language, following on a dialect called B, which
incidentally did not descend from A (and certainly not A Programming
Language, better known as APL), has taken increasing prominence in the
Nineteen Eighties and early Nineties. Were it not for the vast legacy
of COBOL Applications still used in business Data Processing, it would
be without doubt the most common Programming paradigm.
It now underlies all sorts of computing, from Operating Systems, in
particular UNIX, but also the Microsoft Windows family, to commercial,
mathematical and scientific Packages. For the luddites, it has
definitely supplanted BASIC in games Programming. Finally, it forms the
base on which the Object Programming Language C++ was built. In fact,
C++ represents a straight superset of C, so that its own explosion
in the late eighties in no way implies the demise of C itself.
Despite this huge success, the Language betrays its origins as a Systems
programming tool. It was meant to reduce the need for Assembler Coding,
and its designers did not really consider its suitability for other
purposes. The Language goes against several general features of its
contemporaries. At times this simply runs against established instincts,
but in other areas, I can only describe C as a large retrograde step.
So, my first suggestion has to be do you truly need it ?. If youve
heard its much better than Fortran or Pascal, and you are a competent
Programmer in these, than you could do much worse than carry on with
them or look into Fortran 90. Certainly, your productivity will not be
exposed to the severe drop that accompanies a transition to C, at the
very least for an extended learning curve period.
For the brave who feel they must become acquainted with this widespread
Programming language, this set of lectures will present the key features
in the Language, together with advice on avoiding some common pitfalls.
- 2/ Arrays
- 3/ Array Bounds
- Formatting is difficult,
Robust Input Validation forces lots of Code.
- 6/ Standards
- 2/ Argument Passing
- 3/ Dynamic Storage
- 2/ Consistency
- 3/ Poor Diagnostics
- 4/ Interfacing
- 2/ Type Prefixes
- char
- int
- Integer
- long
- float
- Real
(limited Precision).
- double
(normally 8 Bytes,
best for Calculations).
- long
- short
- int
- signed
- char
- int
"
"
- unsigned - char
- int
(Range 0 to 255),
(always Positive,
all Bits make Value).
- auto
- const
- extern
- In Data Declarations,
place Scope before Variable Type and Prefix,
like
or
- 4/ Conversions
long *ll
ll
*ll
ll + 1 = ll + sizeof ( long ).
ll = ( &name + 4 ), effectively,
ll = ( &name + 4 * sizeof ( long ) ),
for address 4 Logical Units off &name.
&name_1 = &name_2,
&name
= ll
illegal,
long
long
ll [NN];
ll []
= { 1, 2, 3, 4 };
where
and
so
unlike
struct
struct
struct
struct
struct
stdata
stdt01 = { "Nstr",
,
20
,
,
"Data" } ;.
struct
stdata
stdt01 [NN] ;.
long
ll [ N1 * N2 * N3] ;,
long
giving
not
long
giving
ll [3] [2] = { { 1 },
{ 2 }, { 3, 4 } };,
10
or
ll
= Address of ll [0],
ll + 1 =
"
" ll [1].
that is ll
= &ll [0],
and
ll + 1 = &ll [1], or ( &ll [0]) + 1.
- Can equate Pointer to Array, but not contrary,
or can use [] Offsets with Pointers,
but only to get Values (in effect dereferencing),
like
long
long_pt
*long_pt;,
= ll;,
or
long_val =
long_pt [2];
= *(long_pt + 2);,
but not ll
=
long_pt,
or
*long_pt [2] (use *(long_pt + 2).
- Key Array/Pointer difference is former fixed,
and represent actual Memory Locations with Data,
whilst latter can change but holds no Memory.
11
long
double
double
lneg
lpos
dneg
dpos
= -10
= 15
= -25.75
= 25.25
,,
;,
,,
;,
give
and
lneg
lpos
= dneg ; as -25,
= dpos ; as +25,
but
and
dneg
dpos
= lneg ; as -25.00,
= lpos ; as +25.00.
int
long
float
double
ii
ll
ff
dd
=
15
= -75000
=
25.75
= -85000.85
;,
;,
,,
;,
give
ii
ii
= ll ;,
= dd ; both uncertain,
and
ff
= dd would be uncertain,
when dd very large,
in terms of Exponent.
12
ii ;,
ll ;,
dd ;,
assign. ll =
becomes ll = (long)
ii ;,
ii ;,
and
dd =
ll ;,
becomes dd = (double) ll ;,
or with
int
unsigned int
double
ii ;,
iu ;,
dd ;,
assign. ii =
iu ;,
becomes ii = (signed) iu ;.
- 2/ Arithmetic
Operators
:
:
:
:
:
+ (allowed on Pointers),
- (
"
"
"
),
*,
/,
% (remainder in Integer Divide).
13
: double
float,
long
int
Bottom : char
int
long
double
ii ; ,
ll ; ,
dd ; ,
expr.
becomes
(long)
ii * ll ,
ii * ll ,
and
becomes
ii * dd ,
(double) ii * ll .
long
double
*lp ; ,
*dp ; ,
expr.
becomes
lp
lp
+ 4
,
+ 4 * sizeof (long) ,
and
becomes
dp
dp
- 5
,
- 5 * sizeof (double) ,
but
becomes
dp
dp
+ ip
,
+ ip * sizeof (double) .
14
- 5/ Operator
Overload
long
long
long
la ; ,
lb ; ,
*lp ; ,
mean
la
same as la
=
=
la*lb
; ,
la * lb ; ,
but
la
same as la
=
=
la*lp
; ,
la * lp ; ,
with
lp
15
++ll
: Add 1 to ll,
before computing any expression,
where ll involved,
called "prefix" Mode,
--ll
So, in expressions,
Prefix Mode Increments take precedence,
while Postfix Increments computed after all of rest.
Note Increments can result in multiple Assignments,
in one Assignment Statement (Result = Expression),
with some to Variables in Right hand side,
and not always of same Type as Left hand side,
16
long
long
long
la ; ,
lb ; ,
*lp ; ,
assign.
same as la =
la++
; ,
( la + 1 ) ; ,
assign.
same as la =
but
--la
; ,
( la - 1 ) ; ,
la-; clearer here,
and
lp =
same as lp =
that is lp =
--lp
; ,
( lp - 1
) ; ,
( lp - sizeof (long) ) ; ,
but
lb =
same as la =
then
lb =
++la + 5
; ,
( la
+ 1 ) ; ,
la
+ 5
; ,
and
lb =
same as lb =
then
la =
la-- + 5
; ,
la
+ 5
; ,
( la
- 1 ) ; .
17
long
long
long
la ; ,
lb ; ,
lc ; ,
give
same as la =
la += 3
; ,
( la + 3 ) ; ,
and
same as la =
la *= 7
; ,
( la * 7 ) ; ,
and
la -=
same as la =
lb / lc
; ,
( la - ( lb / lc ) ) ; .
18
: <,
: <=.
long
long
Test
(la != lb + 5 ),
means
However
( la == lb++ + 5 ),
means
Likewise ( la
means
and
la ; ,
lb ; ,
19
: double
float,
long
int
Bottom : char
int
long
double
ii ; ,
ll ; ,
dd ; ,
cond.
becomes
(
( (long)
ii == ll ),
ii == ll ),
and
becomes
(
ii >
( (double) ii >
20
dd ),
dd ).
&&
||
for
for
"And" Logic,
"Or"
" .
long
long
la ; ,
lb ; ,
cond.
same as
(
la
( ( la
meaning
but
( ( la
( lb
means
== lb
||
la >
== lb ) || ( la >
== lb
>= 56
21
||
||
lb + 12
),
lb + 12 ) ),
la > lb + 12 ) &&
lb < -24
) ) ,
long
long
Block
if
la
la ; ,
lb ; ,
la != lb + 5 ) { ,
lb
+=
5 ;
,
,
*=
12 ;
means
when
and
la incremented 5 Units,
la not same as lb,
lb anyway doubled afterwards.
However
if
la
means
but
+=
5 ;
,
,
Likewise if
}
means
when
la == lb++ + 5 ) { ,
( la
,
,
22
long
long
write
if
la ; ,
lb ; ,
,
,
,
else
if ( lb
,
,
,
< 0 ) { ,
23
long
long
can test if
la ; ,
lb ; ,
( la = printf ( "%d", lb ) == 0 ) { ,
if
lb >=
1 )
lb ==
,
0" ) ;
,
,
0 )
,
,
0" ) ;
24
,
.
so with
long
long
*la ; ,
*lb ; ,
Block
while (
printf
la++
la < lb ) {
( "Data
%d", *la ) ; ,
; ,
,
do
printf
la++
}
while (
( "Data
la < lb )
%d", *la ) ; ,
; ,
,
; ,
25
: for ( la = lb - 100 ;
la < lb ;
la++
; ) {
printf
( "Data
,
,
,
%d", *la ) ; ,
,
26
continue ,
abort current iteration,
and proceed to test whether more needed,
or
to
break ;,
abort current iteration,
and any other iterations in Loop,
so with
long
long
Loop
*la ; ,
*lb ; ,
: for ( la = lb - 100 ;
la < lb ;
la++
; ) {
if
,
,
,
( *la < 0 )
; ,
break
; ,
elseif
( *la == 0 )
continue
printf
( "Data
; ,
; ,
%d", *la ) ; ,
,
27
-10/ Branches
goto lab
; ,
...
lab : la++ ; .
switch ( ex ) {
case
,
ex_val_1 :
ex_val_2 :
,
,
,
,
,
,
.
28
1/ Programs
rtpe
where
or
/* Variable Declarations ,
*/
.
29
2/ Directives
like #define
MEMBK 1024,
3/ Prog. Arguments
l1
[MEMBK] ;,
l2 = MEMBK ;.
main ( int
argc,
char *argv [ ] )
K&R
main (
C : void
argc
argv
int
char
,
)
,
{ } ,
,
,
argc
;
,
*argv [ ] ; { } .
30
4/ Sub-Programs
31
5/ Function Entries
and Prototypes
- Entry and First Statement to a Function,
sets Type of returned Value, names Function,
and Declares any (Optional) passed Arguments.
Syntax same as for main Program Entries,
thus differs in ANSI Standard C and K&R C,
ANSI C : long
func ( int
double
arg_1,
,
arg_2 ) { } ,
K&R
func (
arg_1,
arg_2 )
C : long
int
double
,
,
arg_1 ;
,
arg_2 ; { } ,
func ( int
double
K&R
func ( );
C : long
32
arg_1,
,
arg_2 ); ,
.
33
7/ Libraries
(math) :
(stdlib) :
34
8/ Lib. Inclusion
#include
#include
#include
#include
<math.h>
<stdio.h>
<stdlib.h>
<string.h>
/*
*
*
*
*
*/
Specific Libraries :
,
,
,
,
,
,
Note Names Double Quoted,
,
rather than between < >, ,
reserved for Standard Libs. ,
,
#include "inacn_.h"
,
,
void main
,
,
,
( int
char
argc
,
*argv [] )
35
9/ Func. Arguments
func ( long
K&R
larg ) ,
{ Code } ,
C : void
func (
larg ) ,
long
arg_1; ,
{ Code } .
36
int
double
long
arg_1 ;
arg_2 ;
retv ;
,
,
,
Header :
ANSI long
func ( int
*arg_1,
double *arg_2 );
K&R
func ( );,
Call
long
: retv = func (
&arg_1,
&arg_2 );
,
,
,
.
Arguments :
like
int
*arg_1 ;
double *arg_2 ;
long
retv ;
or
int
double
long
,
,
,
arg_1 [NN] ; ,
arg_2 [NN] ; ,
retv
; ,
Header :
Call
ANSI long
func ( int
*arg_1,
double *arg_2 );
,
,
K&R
func ( );
long
: retv = func (
37
arg_1,
arg_2 );
and
int
double
long
: retv = func (
38
arg_1 [NN] ; ,
arg_2 [NN] ; ,
retv
; ,
arg_1,
arg_2,
NN
);
,
,
.
- 2/ Test outcome
- 3/ Scope
- 4/ Size
- Dynamic
involve
as well
so only
39
- 6/ General Method
- calloc
- free
- malloc
- realloc
40
tot_mat = 512 ;
( ( mat = (double *)
calloc
( tot_mat, sizeof (double) ) ) == NULL ) {
/* Send Error Message to Default Output Unit (usually Screen).
*/
fprintf ( stderr,
"\n\nProgram : %s, Contig. Memory Allocate failed",
argv [0]
);
/* Terminate complete Program Unit, back to Operating System,
* usually with a non Zero Value (often called Return Code),
* eventually attempting to Close any Data Files still open.
*/
exit ( 9 );
}
/* Normal execution of Program continues from here ...
*/
41
(double *)
free
( mat );
42
tot_mat = 512 ;
if
( ( mat = (double *)
malloc
( tot_mat * sizeof (double) ) ) == NULL ) {
43
tot_mat = 512 ;
if
( ( mat = (double *)
realloc ( mat,
tot_mat * sizeof (double) ) ) == NULL ) {
44
#include <stdio.h>,
#include <stdlib.h>,
#include <string.h>.
45
FILE
*pfname ;.
46
= "Standard Input",
= "Standard Output",
= "Standard Error".
47
for Read
(not allowing Write),
" Write (extant Data lost),
" Append (Write Data at Tail),
pfinp = fopen
pfout = fopen
( file_name, "r" ) ;,
( "out.dat", "w" ) ;.
like
irtc
48
fclose ( pfinp ) ;,
= fclose ( pfout ) ;.
like
irtc
irtc
- rewind
like
like
fseek
( pfinp,
10, SEEK_CUR ) ;,
fseek
( pfinp, -10, SEEK_END ) ;.
rewind
irtc
- ftell
( pfinp ); , or,
fseek
( pfinp, 0, SEEK_SET ) ;.
ftell
( pfinp ) ;,
49
irtc
irtc
50
like
feof
( pfinp ) ;,
like
ferror
( pfinp ) ;,
like
fflush
( pfout ) ;,
51
- 8/ Raw Character
I/O Functions
: Read
fgetc
"stdin"
) ;,
( a,
"stdout" ) ;,
) ;.
52
like
like
53
like
like
( pntr
) ;,
like
( pntr, file ) ;,
like
( pntr
) ;,
54
fscanf
like
fscanf
( fileptr,
"%d %d", *dat1, *dat2 ) ;,
- sscanf
dat1,
) ;,
dat2 ) ;,
55
= Single Character,
= Decimal Integer,
=
=
=
=
p
s
56
Decimal Integer,
Octal Integer,
Unsigned Decimal Integer,
Hexadecimal Integer,
w
.p
Long Codes : l
L
Examples
57
like
( chst1, chst2 ) ;,
like
( chst1, chst2 ) ;,
( chst1, chst2 ) ;,
58
( chst1, c ) ;,
like
( chst1
) ;,
- strspn
like
( chst1, chst2 ) ;,
( chst1, chst2 ) ;,
59
( stderr,
%ld",
&irtc ) ;.
fprintf ( stderr,
"\nRet = %ld",
irtc ) ;.
60
61
LL
80
62
fckdou
( FILE
char
*pfinp
,
*descrip ,
long
*tot_val ,
double
double
double
double
*val_min
*val_max
*avg_val
*var_val
char
**mess
,
,
,
,
)
{
/*
*
*/
/*
*/
char
errms
inpt
/*
*
*
*/
double
in_sum
in_ssq
in_val
tv_dou
/*
*/
int
irtc
[LL] ,
[LL] ;
,
,
,
;
63
( irtc
= ftell ( pfinp ) != 0
fprintf
( stderr,
"\n\nData File not at start (Zero Offset)" );
fprintf
( stderr,
"\n\nData File repositioned to beginning"
if
) {
);
( irtc
fprintf
( stderr,
"\n\nPre-check File Rewind failed" );
return
( 01
);
}
}
/* Initialise Total (number of) Values Input from File.
*/
*tot_val
= 0;
64
) == 1
) {
( strpbrk
) {
sprintf
( errms,
"%s : Non numeric data at value %ld",
descrip, ( *tot_val + 1 )
);
*mess
return
= errms;
( 11
);
}
else {
/* Once (some) Digits found in Input Data String,
* check no invalid Characters mixed in, that is,
* no non Digits, Sign, Dec. Point, Space or Tabs.
*/
if
) {
sprintf
( errms,
"%s : Illegal chars in value %ld",
descrip, ( *tot_val + 1 )
);
*mess
return
= errms;
( 12
);
}
}
/* while Loop continued on next Page ...
*/
65
( *tot_val
in_sum
in_ssq
if
if
( in_val
( in_val
> 1
) {
+= in_val;
+= in_val
* in_val;
> *val_max )
< *val_min )
*val_max = in_val;
*val_min = in_val;
}
else {
in_sum
in_ssq
= in_val;
= in_val
*val_max
= *val_min = in_val;
}
}
66
* in_val;
( irtc
= feof
( pfinp ) == 0
fprintf ( stderr,
"\n\nData File not at end after all Input\n"
exit
( -1
) {
);
);
}
/* Once all Data Points input, rewind Data File,
* by placing pointer, with offset zero, at top of File.
* When Error, send Error signal back to calling Routine,
* which may reattempt Rewind, or Terminate Program.
*/
if
( irtc
fprintf ( stderr,
"\n\nData File Rewind error after Data Check"
return
( 21
);
67
) {
);
( *tot_val
> 0
) {
tv_dou
= (double) *tot_val;
*avg_val
= ( in_sum / tv_dou
);
( *tot_val
> 1
*var_val
= (
) {
(
in_ssq
- tv_dou * *avg_val * *avg_val )
/ (
tv_dou - 1.0
) );
}
else {
*var_val
= 0.0;
}
}
else {
/* All File Statistics Zero when no Data in File.
*/
*val_max
= *val_min
= *avg_val
= *var_val
= 0.0;
}
/* Return to calling Routine once File processed.
*/
return
( 0
);
68
69
/*
*/
#define
#define
#define
DEF_INP "ycvinp.dat"
DEF_MAT "ycvmat.dat"
DEF_OUT "ycvout.dat"
/*
*/
#define
LL
/*
*/
#include
#include
#include
#include
/*
*/
80
<math.h>
<stdio.h>
<stdlib.h>
<string.h>
Called Functions Prototypes (Headers).
#include "fckdou.h"
70
argc
,
*argv [] )
*pfinp
*pfmat
*pfout
,
,
;
finp_name [LL] ,
fmat_name [LL] ,
fout_name [LL] ;
*fptr_name ,
inpt
*mess
[LL] ,
= "" ;
71
*mat
yel
,
;
avg_mat
max_mat
min_mat
var_mat
,
,
,
;
irtc
ii
tot_mat
tot_yel
= 0 ,
= 0 ;
72
( argc
> 1
) {
fgets
if
( strlen
( inpt ) <= 1 ) {
fptr_name = DEF_INP;
}
else {
fptr_name = strtok ( inpt, " \t\n" );
}
}
/* Assign Input File Name off Generic Name Input String.
*/
sprintf
73
( argc
> 2
) {
fgets
if
( strlen
( inpt ) <= 1 ) {
fptr_name = DEF_OUT;
}
else {
fptr_name = strtok ( inpt, " \t\n" );
}
}
/* Assign Output File Name off Generic Name Input String.
*/
sprintf
74
( argc
> 3
) {
fgets
if
( strlen
( inpt ) <= 1 ) {
fptr_name = DEF_MAT;
}
else {
fptr_name = strtok ( inpt, " \t\n" );
}
}
/* Assign Maturities File Name off Generic Name Input String.
*/
sprintf
75
) {
fprintf
fprintf
);
);
exit
( 01
);
}
/* Attempt opening Output Data and Maturities Files,
* with Input closure and immediate termination when Error.
*
* Once Termination Block entered, Input File closed directly,
* while Output File needs no closure as opening failed.
*/
if
) {
fprintf
fprintf
fclose
( pfinp );
exit
( 02
);
76
) {
fprintf
fprintf
);
);
fclose
fclose
( pfinp );
( pfout );
exit
( 03
);
}
/* Scan and check Maturities (expected in Years) before input,
* with outside Function (all values must be valid numbers).
* Total values, min. max. average and variance returned, but,
* Output message and quit when non Zero Code flags an Error.
*/
irtc = fckdou ( pfmat
, "Maturities File",
&tot_mat, &min_mat, &max_mat,
&avg_mat, &var_mat, &mess
);
if
) {
( irtc
!= 0
fprintf
fprintf
fclose
fclose
fclose
( pfinp );
( pfout );
( pfmat );
exit
( 04
);
77
( ( mat = (double *)
malloc
( tot_mat * sizeof (double) ) ) == NULL ) {
fprintf
fclose
fclose
fclose
( pfinp );
( pfout );
( pfmat );
exit
( 11
);
}
/* Copy valid Maturities from File to Local Array.
*
* Note use of Array Notation with Pointer to Array.
*/
for ( ii = 0;
if
) {
( ( irtc
fprintf
( stderr,
"\n\nMaturity Value No. %ld input error\n",
( ii + 1 )
);
fclose
fclose
fclose
( pfinp );
( pfout );
( pfmat );
exit
( 12
);
}
}
78
) {
( ( irtc
) {
fprintf
);
fclose
fclose
( pfinp );
( pfout );
exit
( 13
);
}
/* Present Maturities summary after successful scan and Input.
*/
fprintf
fprintf
fprintf
( stderr, "\n\nFile
: %s
",
fmat_name
);
( stderr,
"\nTotal Values : % 6ld",
tot_mat
);
fprintf
( tot_mat <= 0
) {
fprintf
fclose
fclose
( pfinp );
( pfout );
exit
( 14
);
79
= 0; ii < 2; ii++
irtc
) {
= ;
while ( irtc != \n
irtc
= fgetc
) {
( pfinp );
}
}
/* Pick successive Yield Curves (one per Line).
*
* End of File used as Loop repeat Condition,
* but exit likely with trying Input of fresh Line,
* so at stage of discarding unwanted Date Field.
*/
while ( irtc
!= EOF
) {
( ( irtc
= fscanf
break;
}
/* Loop (while) continued ...
*/
80
) {
( ( irtc
fprintf
( stderr,
"\n\nYield Curve point input error\n"
fclose
fclose
( pfinp );
( pfout );
exit
( 21
( ( irtc
= fprintf ( pfout,
"% 6.2lf % 6.2lf
mat [ii], yel
!= 1
) {
);
);
}
if
",
) ) < 0
) {
fprintf
( stderr,
"\n\nYield Curve point output error\n" );
fclose
fclose
( pfinp );
( pfout );
exit
( 22
);
}
}
/* Loop (while) continued ...
*/
81
( ( irtc
fprintf
( stderr,
"\n\nYield Curve Line end output error\n"
fclose
fclose
( pfinp );
( pfout );
exit
( 23
< 0
) {
);
);
}
/* Once Current Yield Curve successfully written to Output,
* add to Total Curves processed (and Current Curve number).
*/
tot_yel++;
}
82
( ( irtc
= fclose
( pfinp ) ) == EOF
) {
fprintf
( stderr, "\n\nInput
fclose
( pfout );
exit
( 31
( ( irtc
= fclose
fprintf
exit
( 32
);
}
if
( pfout ) ) == EOF
) {
);
}
/* Present Data summary after successful copy to Output File.
*/
fprintf
fprintf
fprintf
fprintf
fprintf
",
);
",
);
",
);
83
Date
01/02/91
01/03/91
01/04/91
01/07/91
01/08/91
01/09/91
01/10/91
01/11/91
01/14/91
01/15/91
01/16/91
01/17/91
01/18/91
01/22/91
01/23/91
01/24/91
01/25/91
01/28/91
01/29/91
01/30/91
01/31/91
3-mo
6.66
6.64
6.73
6.71
6.64
6.44
6.40
6.34
6.24
6.23
6.22
6.30
6.24
6.24
6.32
6.31
6.35
6.44
6.41
6.39
6.37
84
1991
7-yr
7.90
7.86
7.94
8.04
8.06
8.12
8.02
8.06
8.09
8.07
8.09
7.93
7.92
7.94
7.91
7.88
7.93
7.93
7.90
7.90
7.89
10-yr
7.97
7.93
8.02
8.13
8.16
8.25
8.16
8.20
8.23
8.22
8.24
8.05
8.03
8.07
8.04
8.00
8.06
8.06
8.03
8.05
8.03
30-yr
8.14
8.11
8.20
8.32
8.37
8.46
8.37
8.39
8.41
8.41
8.40
8.18
8.17
8.23
8.21
8.18
8.24
8.23
8.20
8.23
8.21
6.66
0.25
6.64
0.25
6.73
0.25
6.71
0.50
5.00
0.50
5.00
0.50
5.00
0.50
5.00
6.73
7.59
6.71
7.56
6.82
7.65
6.84
7.75
1.00
7.00
1.00
7.00
1.00
7.00
1.00
7.00
6.74
7.90
6.72
7.86
6.83
7.94
6.84
8.04
85
2.00
10.00
2.00
10.00
2.00
10.00
2.00
10.00
7.08
7.97
7.08
7.93
7.17
8.02
7.20
8.13
3.00
30.00
3.00
30.00
3.00
30.00
3.00
30.00
7.30
8.14
7.27
8.11
7.37
8.20
7.43
8.32
Lines :
21
86
#include <math.h>
#include "fckdou.h"
- 4/ Include Argument Count (int argc) and Array (char *argv []),
in main Statement, so it takes a uniform syntax.
- 5/ Put all Data declarations at Top of Source Code,
best in Alphabetical Order of Types, and Names within Type,
Can Present one variable per line, in Column fashion,
Pointers * standing out, Array Sizes or Initial Values on Right.
Avoid Single Letter Names, overly long ones, clashes with Language,
like int if, and, possibly, common English and Mathematical terms.
Can be useful for first Letter to indicate Type (say i for int).
87
88
89
90
91
92
93