Date post: | 05-Dec-2014 |
Category: |
Technology |
Upload: | jam-catipon |
View: | 411 times |
Download: | 0 times |
Global and Local Variables
GAME:PUZZLE
WHAT IS GLOBAL
VARIABLE
WHAT IS LOCAL
VARIABLE
quiz
Puzzle Game
GROUP 1 GROUP 2
Dacanay FernandezDongon ArnigoFlora BadeUy GarciaLopez Navaroza
Fuentes ArevaloGuillermo Dacquel
De Guzman IgnacioArenas MalagdayCrispino Manubag
Puzzle Game
GROUP 1 GROUP 2
Bagabag BuendiaCatipon LampanoLining LopezSagun AggasidCuerdo LagrisolaAdarlo Antonio
Llao FrancoDealca Nunez
Macaspac RamirezValenzuela Mariano
Balderama DantesMabaet
program Factorprog;Uses crt;Var No: integer;
Function Factor(N:integer): integer;Var
F,I: integer;BeginF:=1;For I:=N down to 1 doF:= F*I;Factor:=F;End;
BeginClrscr;Writeln(‘Enter a number:’);Readln(No);Writeln(‘The Factorial Value:’, Factor(No));Readln;End.
Global Variable
are accessible from anywhere in the program
and retain their values until the document is unloaded.
Local Variable
are created during functioncalls for temporary use and are accessible only within
the functions that create them.
program Factorprog;Uses crt;Var Base, Expo: integer;Function Power (B: integer; E: integer) : integer;Var P: integer; I: integer;BeginP:= 1;I:= E;RepeatP:=P*BI:= I-1;Until (I=0);Power:=P;End;
BeginClrscr;Writeln(‘Enter base number:’);Readln(Base);writeln(‘Enter exponent number:’);Readln(Expo);Writeln(‘Power Value:’, Power(Base, Expo));Readln;End.