EasyManuals Logo
Home>Casio>Desktop>FX-890P

Casio FX-890P User Manual

Casio FX-890P
126 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #102 background imageLoading...
Page #102 background image
102
6.1 Constants and Variables
6.1.1 Local variables and global variables
Local variables
A local variable is one that is declared within a function for use within that particular
function only.
Since such variables are local, you can use the same variable name in multiple
functions without any problem – each variable is treated independently, even though
they have the same name. Have a look at the program listed below.
/* Local variable */
/* #include <stdio.h> */
void pr() /* print function */
{
int i; /* local i */
for(i=0;i<2;i++)
printf(“%d “,i);
}
main(){
int i;
for (i=0; i<10; i++)
pr();
}
This program displays ten sets of numbers 0 and 1. Both the main() function and the
pr() function utilize variable “i” but the computer treats these as two entirely different
variables. In the main() function, the value of “i” ranges from 0 to 9, while in pr() it is 0
or 1 only.
Global variables
A global variable is one that is commonly applied throughout all functions of a
program. Global variables are declared in the line before preceding the main() line
and the other functions using them. Have a look at the program listed below.
/* Global variable */
/* #include <stdio.h> */
int i /* global i */
void pr() /* print function */
{
printf(“%d “,i);
}
main(){
for (i=0; i<10; i++)
pr();
}

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Casio FX-890P and is the answer not in the manual?

Casio FX-890P Specifications

General IconGeneral
BrandCasio
ModelFX-890P
CategoryDesktop
LanguageEnglish

Related product manuals