![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
Pascal Question
Ok, I´ll say what the problem is: the command "while not keypressed do" just function when D<0..well that's a real big problem because D can also be >0 and then the window closes before showing the coordinate of the vertex of the parable... NOTE: some of this program is in Portuguese, but it should not matter.
__________________
+_-¤ ŦĦễ £ﺄĢĦŧňĨňĢĦǻщk ¤-_+ Last edited by big_k105; Jun 6th, 2005 at 9:32 AM. |
|
|
|
|
|
#2 |
|
Programmer
|
Ok.... umm... Why did it post all short and scrawny like that?
Would someone please tell me how to fix that?
__________________
+_-¤ ŦĦễ £ﺄĢĦŧňĨňĢĦǻщk ¤-_+ |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Sure. Press enter once in a while.
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: May 2005
Posts: 48
Rep Power: 0
![]() |
Hi....LOL...that's my program....
![]() |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jun 2005
Posts: 86
Rep Power: 4
![]() |
You've got a couple of missing begin...end blocks here. Because of that, you're evaluating:
raiz2 := (-b - sqrt(d))/(2*a); even when d is negative, which would cause your program to abort (because of the part in bold text). You also have some unnecessary begin..end blocks. Restructuring your code around a bit, I ended up with: program FormulaResolvente;
uses
crt;
var
A : real;
B : real;
C : real;
D : real; {o k ta dentro da raiz kuadrada da formula resolvente}
X : real; {coordenada X do vertice}
raiz1 : real;
raiz2 : real;
Begin
clrscr;
writeln( 'Introduz o valor de A:' );
readln( A );
writeln( 'Introduz o valor de B:' );
readln( B );
writeln( 'Introduz o valor de C:' );
readln( C );
d:= (b*b)-(4*a*c);
if d < 0 then
writeln('Raizes de nºs negativos nao existem Razz')
else
begin
raiz1:= (-b+sqrt(d))/(2*a);
raiz2:= (-b-sqrt(d))/(2*a);
writeln('1ª Raiz = ',raiz1);
writeln('2ª R aiz = ',raiz2);
X:= (raiz1+raiz2)/2;
writeln('Coordenada X do vertice : ',X);
writeln('Coord enada Y do vertice : ',(A*sqr(x))+(B*X)+C);
end;
while not keypressed do;
end. |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|