Variable Types And Operations - Casio FX-890P Owner's Manual

Casio personal computer owner's manual
Table of Contents

Advertisement

The following results would be displayed:
.R U N .
.

6.2.2 Variable types and operations

Declaring variable types
With C programs, you have to declare the type of data that will be assigned to each
variable before you can use the variable. The following statement, for example, tells
the computer that the variable "x" will be used for the storage of integers:
int x;
The following table shows the other declarations that can be made for variables.
Declaration
Meaning
char
8-bit integer
short
16-bit integer
int
16-bit integer*
long
32-bit integer
float
32-bit single precision floating point
double
64-bit double precision floating point
Besides these, you can also include the declaration "unsigned" in front of any of the
integer declaration (except long) to indicate that the integer is unsigned (no
positive/negative sign)
*Note: the "int" declaration is hardware dependent, despite the fact it is the default
type in many cases, and the fastest for arithmetics. On the pocket computer, which
uses a 16-bit microprocessor, it refers to a 16-bit integer. But on other processors, it
may refer to 24-bit or 32-bit integers. For best portability, it is recommended to use
the "short" declaration instead, when possible.
Assigning values to variables
To see how to declare variables and also how to assign values, let's write a program
that performs various operations using the values 49 and 12.
Enter the editor and input the following program.
/* Arithmetic Operations 1 */
main(){
short a,b,c,d,e;
a=49+12;printf("%d
b=49-12;printf("%d
c=49*12;printf("%d
d=49/12;printf("%d
e=49%12;printf("%d¥n",e);
>run
D=65 O=101 H=41 C=A
>_
",a);
",b);
",c);
",d);
88

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents