0

i just recently started with pascal, and I have no idea what the compiler tries to tell me. Can anyone tell me whats wrong with these procedures?

Uses Crt;

var
	Answer: Real;
	AnswerB : Real;
	AnswerC: Real;

(******************************************************************************************)

procedure GetData;

var
	A : Real;
	B : Real;
	c : Real;

begin
	Writeln ('Input value a');
	Readln (a);
	Writeln ('Input value b');
	Readln (b);
	Writeln ('Input value c');
	Readln (c);
	Discriminant (a,b,c);
end;

(******************************************************************************************)

procedure Discriminant;

begin
	If ((b*b-(a*a*a*a*c)) > 0)
	then Writeln ('There are two different types of roots.');
	If ((b*b-(a*a*a*a*c)) = 0)
	then Writeln ('The two roots are equal.');
	If ((b*b-(a*a*a*a*c)) < 0)
	then Writeln ('There are no real roots.');
	MaxMin (a,b,c);
end;

(******************************************************************************************)

procedure Vertex;

begin
	AnswerC := -b/(2*a)
	Writeln ('The Vertex of the equation is ', AnswerC:1:2 ,'.');
end;

(******************************************************************************************)

procedure MaxMin;

begin
	If AnswerC > 0
	Then WriteLn ('It is the Maximium.');
		else
		WriteLn ('It is the Minimum.');
end;
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by FlamingClaw
0

You have to learn more about procedures,and its parameters :D
I fixed your code :D

program sablon;
Uses Crt;
var
	Answer  : Real;
	AnswerB : Real;
	AnswerC : Real;
{***}
{FIXED HERE!NOW YOU CAN INITIALIZE THE THREE REAL NUMBERS}
procedure GetData(VAR A,B,C:REAL);
begin
	Writeln('Input value a');
	Readln(A);
	Writeln('Input value b');
	Readln(B);
	Writeln('Input value c');
	Readln(C);
end;
{***}
{FIXED WITH FORMAL PARAMETERS,NOW IT CAN CALCULATE !}
procedure Discriminant(A,B,C:REAL);
begin
	If ((b*b-(a*a*a*a*c)) > 0)
	then Writeln ('There are two different types of roots.');
	If ((b*b-(a*a*a*a*c)) = 0)
	then Writeln ('The two roots are equal.');
	If ((b*b-(a*a*a*a*c)) < 0)
	then Writeln ('There are no real roots.');
end;
{***}
{FIXED!}
procedure Vertex(A,B,C:REAL);

begin
	C := -b/(2*a);
	Writeln ('The Vertex of the equation is ',C:1:2 ,'.');
end;
{***}
{FIXED!}
procedure MaxMin(C:REAL);
begin
	If (C > 0)Then WriteLn('It is the Maximium.')
	else writeLn ('It is the Minimum.');
end;

{AND HERE BEGINS THE MAIN PROGRAM}
begin
     clrscr;
     {CALL THE PROCEDURES ONE BY ONE}
     GETDATA(ANSWER,ANSWERB,ANSWERC);
     DISCRIMINANT(ANSWER,ANSWERB,ANSWERC);
     MAXMIN(ANSWERC);
     VERTEX(ANSWER,ANSWERB,ANSWERC);
     readln;
end.
{Fixed by FlamingClaw 2009}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.