Hi.. welcome to my site in “We Are Knowledge”… In here you
will getting many IT knowledge, because I was provided many tutorial about it.
I was provided like as :Web programming likely : PHP,HTML,
Dekstop programming like as : Cobol, C++, VB 6, Pascal (I will discuss this),
and other program language, and I have also provided general knowledge, like as
: receip of Indonesian foods asnd Design grafis using “adobe photoshop”.
Now, I want giving you knowledge about program language “pascal”and
disscus about ”Function in Pascal”. Ok.. let’s do read my article… !!
Pascal is program language based Dekstop, And has its own
compiler does not like that do not have one cobol. Function in Pascal likely
block procedure in pascal too. And function is program modules that produce a
quantity.
Syntax :
FUNCTION name : type of
result;
or
FUNCTION name (formal parameter : type ) : type of result;
Ok.. direct to program..
You can copythis and paste in your compiler likely : “turbo
pascal”.
Example 1:
uses crt;
Function sum(Var A,B,C,D,E : integer): integer;
Begin
sum := A + B + C + D + E;
End;
Var K,L,M,N,O : integer;
Begin
clrscr;
Write('Value K ? ');
Readln(K);
Write('Value L ? ');
Readln(L);
Write('Value M ? ');
Readln(M);
Write('Value N ? ');
Readln(N);
Write('Value O ? ');
Readln(O);
Writeln;
writeln;
Writeln(K, ' + ',L, ' + ',M, ' + ',N, ' + ',O, ' = ', sum(K,
L, M, N, O));
writeln ('Please, press enter to exit');
readln;
End.
Press ”alt + F9”
>> compille program
Press”ctrl + F9” >> running program
To result :
If you input number = “4”, ”8”, ”2”, ”1”, ”5”.
Value K ? 4
Value L ? 8
Value M ? 2
Value N ? 1
Value O ? 5
4 + 8 + 2 + 1 + 5 = 20
Please, press enter to exit
Note ::
Please change all quotes (“ “) or (‘ ‘).
You must aplication for making it
Thanks for visitors…
See you later..
No comments:
Post a Comment