Friday, June 18, 2010

Pascal : Calculation of the rank numbers in addition to the rank of two or quadratic


To calculate the number two in rank than the rank of Pascal, we can not just write 3 ^ 8, but we can use the loop "for do" to calculate it. The following complete code:

uses wincrt;
var i,y,x,z: integer;
begin
     write('Enter digits = ');readln(x);
     write('Enter rank = ');readln(y);
     z := 1;
     for i := 1 to y do
     begin
         z := z * x;
     end;
     write('the result is ',z);
     end.

analysis of these codes:such value and the value of x = 5, y = 5, then we will calculate the 5 ^ 5. 
from the code above, at line

z := 1;

This means that we determine the value of z is 1.
at line

for i := 1 to y do

This means it will repeat the process

begin
   z := z * x;
end;

until the value of y is fulfilled, so if the value of y is 5, that means the process will be repeated five times.
The following are the results of the iteration:
z = 1 * 5 = 5
z = 5 * 5 = 25
z = 25 * 5 = 125
z = 125 * 5 = 625
z = 625 * 5 = 3125
z value of the final result is 3125.
at line
write ('result is', z);
This means it will display the value of z is 3125.
hopefully useful .. ^ _ ^

No comments:

Post a Comment