Casio FX-890P Owner's Manual page 101

Casio personal computer owner's manual
Table of Contents

Advertisement

/* 100 squares 3 */
/* #include <stdio.h> */
double dsquare(x) /* square */
double x;
{
return (x*x);
}
main(){
double d;
for (d=1.0; d<=100.0; d+=1.0)
printf("(%lf)^2=%f¥n",i,dsquare(d));
getchar(); /* waits ret key */
}
Variables are now declared as double precision floating-point. Variables declaration
has to happen before using them in a statement.
Note that we have to start the program with the function, in order to allow calling it
further down.
EXAMPLE 3:
The alternative method is to use declare the function first, so that the interpreter
knows its type, before actually writing the function. Here is an example using function
declaration
/* 100 squares 4 */
/* #include <stdio.h> */
extern double dsquare();
main(){
double d;
for (d=1.0; d<=100.0; d+=1.0)
printf("(%lf)^2=%f¥n",i,dsquare(d));
getchar(); /* waits ret key */
}
double dsquare(x) /* square */
double x;
{
return (x*x);
}
Note that a function declaration of line 3 does not specify the amount and type of
parameters. ANSI C authorizes function prototyping, which would look like:
extern double dsquare(double)
Nevertheless, prototyping is not implemented in the C interpreter of the unit. It is
therefore recommended to write functions before calling them, avoiding parameter
errors that can be hard to debug.
101

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents