I could be wrong here, but IMO the formal parameters are ones the procedure or function is declared with, the actual parameters are the ones passed down to the subroutine upon each call. Usually there is little to no difference between the two because of Pascal's strong typing, but there are some exceptions, for example:[code][color=Blue]procedure do_something(var a); <-- formal declaration begin {...} end;
var x:procedure; y:array[0..3] of pointer;
begin {...} do_something([b]x[/b]); { <-- actual parameter, a procedure } do_something([b]y[/b]); { <-- actual parameter, some pointers } {...} end.[/color][/code]The [b]write[/b] procedure is an another example, look in the help for the formal declaration and observe how many ways the routine can be called by passing different actual parameters.
Alex, thanks for your help.i have another issue bordering me in PASCAL PROGRAMING.I know you can help to solve it at your leisure. the question is:
1.) A college offers a course that prepares students for the state licensing exam for real estate brokers. Last year, 10 of the students who completed this course took the exam. The college wants to know how well it students did in the exam. You have been asked to write a Pascal program to summarize the results.You have been given a list of these 10 students. Next to each name is written a1 if the student passed the exam or a2 if the student failed. The program should analyze the results of the exam as follows: i)Input each test results(i.e,a1 or a2). ii) Count the number of test results of each type iii) Display a summary of the test results indicating the number of students who passed and the number who failed. iv)if more than 8 students passed the exam, print the message "Raise tuition".
I will appreciate your assistance my email add is arimsam@gmail.com
const max_student=10; { maximum number of students } pass_str:array[false..true] of string[2]=('a2','a1');
type student=record name:string[40]; { name of stundent, max 40 characters } pass:boolean; { if is true then passed the exam } end;
var st:array[1..max_student] of student; { <-- students } i,passed,failed:byte; ch:char;
begin passed:=0; failed:=0;
{input} for i:=1 to max_student do begin write(#13#10{cr+lf},'Enter student name ',i,' of ',max_student,' : '); readln(st[i].name); write(' Exam passed ? (y/n) : '); repeat ch:=upcase(readkey); until ((ch='Y') or (ch='N')); writeln(ch); st[i].pass:=(ch='Y'); if st[i].pass then inc(passed) else inc(failed); end;
writeln;writeln; {display} for i:=1 to max_student do with st[i] do writeln(i,' ',name,' --- ',pass_str[pass]);
writeln(#13#10,'Number passed: ',passed); writeln( 'Number failed: ',failed); if passed>8 then writeln('Raise tuition'); readln; end.[/color][/code]
Atex, Your such a great guy. Thanks alot.You can reach me on +2347025001238. i will like to have your phone number too. Am a beginner in pascal and has been facing challanges, which your answers are helping me to pick up.Once more, thank You. your the Man.
Below are some other questions you can help me to look into at your leisure:
1. Write a Program that reads 2 dimensional matrices (say A & of M x N.Your program will compute the ressult matrix C[M,N] to the console (use procedures explicitly).
2. Write a simple Pascal program that can calculate area of any circle.
Seems to me that you want someone to do your homework for you, so no complete code this time.
1. Matrix problem:[code]type _matrix_:array[1..maximum_size,1..maximum_size] of [green][/green]; <-- 2D array to store matrix
[red]{To enter a matrix}[/red] var m:_matrix_; i,j:byte;
for i:=1 to X_size do { X_size, Y_size are the actual sizes of the matrix, must be <= maximum_size } for j:=1 to Y_size do begin write('Enter element (',i,',',j,') : '); readln(m[i,j]); end;
[red]{To display a matrix}[/red] for i:=1 to Y_size do for j:=1 to X_size do begin gotoxy(j*3,i*2); { <-- needs CRT unit } write(m[j,i]); end; writeln;[/code]Now all you need to do is to write the part responsible for doing the math between 2 matrices...
2. Pseudocode for calculating circle area:[code]1. Get user to enter cicle radius ( use: write + readln ) 2. Calculate area ( area = PI * RADIUS^2 ) 3. Display result ( use: writeln ) [/code]
: But am still having issues on the matrice, is really hard for me. : can you help me out and complete it so that it will serve as an : example for me. :
This procedure will multiply 2 square matrices[code][color=Black]procedure matrix_mult(a,b:_matrix_;xy_size:byte;var c:_matrix_); var i,j,k:byte; t:[green][/green]; begin for i:=1 to xy_size do for j:=1 to xy_size do begin t:=0; for k:=1 to xy_size do t:=t+a[i,k]*b[k,j]; c[i,j]:=t; end; end; [/color][/code]Together with the code posted earlier, you should be able to put together a working example. If not, I suggest to read through some tutorials to get the hang of the basics first...
Comments
begin
{...}
end;
var x:procedure;
y:array[0..3] of pointer;
begin
{...}
do_something([b]x[/b]); { <-- actual parameter, a procedure }
do_something([b]y[/b]); { <-- actual parameter, some pointers }
{...}
end.[/color][/code]The [b]write[/b] procedure is an another example, look in the help for the formal declaration and observe how many ways the routine can be called by passing different actual parameters.
thanks for your help.i have another issue bordering me in PASCAL PROGRAMING.I know you can help to solve it at your leisure. the question is:
1.) A college offers a course that prepares students for the state licensing exam for real estate brokers. Last year, 10 of the students who completed this course took the exam. The college wants to know how well it students did in the exam. You have been asked to write a Pascal program to summarize the results.You have been given a list of these 10 students. Next to each name is written a1 if the student passed the exam or a2 if the student failed.
The program should analyze the results of the exam as follows:
i)Input each test results(i.e,a1 or a2).
ii) Count the number of test results of each type
iii) Display a summary of the test results indicating the number of students who passed and the number who failed.
iv)if more than 8 students passed the exam, print the message "Raise tuition".
I will appreciate your assistance my email add is arimsam@gmail.com
uses crt;
const max_student=10; { maximum number of students }
pass_str:array[false..true] of string[2]=('a2','a1');
type student=record
name:string[40]; { name of stundent, max 40 characters }
pass:boolean; { if is true then passed the exam }
end;
var st:array[1..max_student] of student; { <-- students }
i,passed,failed:byte;
ch:char;
begin
passed:=0;
failed:=0;
{input}
for i:=1 to max_student do begin
write(#13#10{cr+lf},'Enter student name ',i,' of ',max_student,' : ');
readln(st[i].name);
write(' Exam passed ? (y/n) : ');
repeat
ch:=upcase(readkey);
until ((ch='Y') or (ch='N'));
writeln(ch);
st[i].pass:=(ch='Y');
if st[i].pass then inc(passed) else inc(failed);
end;
writeln;writeln;
{display}
for i:=1 to max_student do
with st[i] do
writeln(i,' ',name,' --- ',pass_str[pass]);
writeln(#13#10,'Number passed: ',passed);
writeln( 'Number failed: ',failed);
if passed>8 then writeln('Raise tuition');
readln;
end.[/color][/code]
Your such a great guy. Thanks alot.You can reach me on +2347025001238. i will like to have your phone number too. Am a beginner in pascal and has been facing challanges, which your answers are helping me to pick up.Once more, thank You. your the Man.
Below are some other questions you can help me to look into at your leisure:
1. Write a Program that reads 2 dimensional matrices (say A & of
M x N.Your program will compute the ressult matrix C[M,N] to the console (use procedures explicitly).
2. Write a simple Pascal program that can calculate area of any circle.
Expecting to hear from you.Cheers!
1. Matrix problem:[code]type _matrix_:array[1..maximum_size,1..maximum_size] of [green][/green]; <-- 2D array to store matrix
[red]{To enter a matrix}[/red]
var m:_matrix_;
i,j:byte;
for i:=1 to X_size do { X_size, Y_size are the actual sizes of the matrix, must be <= maximum_size }
for j:=1 to Y_size do begin
write('Enter element (',i,',',j,') : ');
readln(m[i,j]);
end;
[red]{To display a matrix}[/red]
for i:=1 to Y_size do
for j:=1 to X_size do begin
gotoxy(j*3,i*2); { <-- needs CRT unit }
write(m[j,i]);
end;
writeln;[/code]Now all you need to do is to write the part responsible for doing the math between 2 matrices...
2. Pseudocode for calculating circle area:[code]1. Get user to enter cicle radius ( use: write + readln )
2. Calculate area ( area = PI * RADIUS^2 )
3. Display result ( use: writeln ) [/code]
thanks, for the guide. It is not that am doing any home work but trying to share knowledge and as well learn. am just trying on my own to learn.
if i have hitches in completing them i will still get back to you.
Thanks a lot.
I was able to complete the area of a circle using the Pseudo codes. Thanks once more.
But am still having issues on the matrice, is really hard for me. can you help me out and complete it so that it will serve as an example for me.
thanks.
: can you help me out and complete it so that it will serve as an
: example for me.
:
This procedure will multiply 2 square matrices[code][color=Black]procedure matrix_mult(a,b:_matrix_;xy_size:byte;var c:_matrix_);
var i,j,k:byte;
t:[green][/green];
begin
for i:=1 to xy_size do
for j:=1 to xy_size do
begin
t:=0;
for k:=1 to xy_size do
t:=t+a[i,k]*b[k,j];
c[i,j]:=t;
end;
end;
[/color][/code]Together with the code posted earlier, you should be able to put together a working example. If not, I suggest to read through some tutorials to get the hang of the basics first...