Jump to content
Sign in to follow this  
Prince of Andalus

Sqrt() Tak Jadi Ler....

Recommended Posts

program sqrt;
var
a,b,c:integer;
x, y, z:real;
begin

     writeln('Enter value of a');
     readln(a);
     writeln('Enter value of b');
     readln(b);
     writeln('Enter value c');
     readln(c);
     writeln('The equation you enter is ', a,'x^2 + ', b,'x + ', c,' = 0');
     readln;

If (a=0) AND (b=0) THEN
     begin
     writeln('There Is No Solution');
     readln;
     end;

If (a=0) THEN
     begin
     x:=-c/b;
     writeln('The Value of x=',x:1:3);
     readln;
     end

else
begin
 y := (-b + sqrt(b*b - 4*a*c))/(2*a);
 z := (-b - sqrt(b*b - 4*a*c))/(2*a);
 writeln('The root values are ', y:1:3 ,' and ', z:1:3);
 readln(y,z);
end;

end.

apasal saya tak boleh guna sqrt?? bila saya tukar sqrt tu ke sqr jadi pulak... tp sqr tu untk kuasa dua, saya nak punca kuasa dua...

saya guna dev-pascal..

http://www.bloodshed.net/download.html

Edited by Prince of Andalus

Share this post


Link to post
Share on other sites

masalah dah setel

saya buat mcm ni

program sqrt;
var
a,b,c:integer;
x, y, z:real;
begin

     writeln('Enter value of a');
     readln(a);
     writeln('Enter value of b');
     readln(b);
     writeln('Enter value c');
     readln(c);
     writeln('The equation you enter is ', a,'x^2 + ', b,'x + ', c,' = 0');
     readln;

If (a=0) AND (b=0) THEN
     begin
     writeln('There Is No Solution');
     readln;
     end;

If (a=0) THEN
     begin
     x:=-c/b;
     writeln('The Value of x=',x:1:3);
     readln;
     end;

If (a<>0) and (b<>0) then
 y := (-b + sqrt(b*b - 4*a*c))/(2*a);
 z := (-b - sqrt(b*b - 4*a*c))/(2*a);
 writeln('The root values are ', y:1:3 ,' and ', z:1:3);
 readln
end;

end.

lecturer yg tolong betulkan...... smile.gif

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...