Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-25-2006, 07:49 AM   #1 (permalink)
joshd's Avatar
 
Master Techie

Join Date: Jun 2005

Location: Bristol

Posts: 2,134

joshd is on a distinguished road

Default trying my hand at pascal.

i have made this:


program AreaOfCircle (input, output);
const
pi = 3.1415926535897932384626433832795;
var
radius : real;
area : real;
procedure pause;
begin
writeln('press any key to exit');
readln;
end;

begin
writeln('enter radius:');
readln(radius);
area := pi * radius * radius;
writeln(area);
pause;

end.


is there an easier way to make the "pause" so the program doesnt't just exit itself after caluclating the value, not giving you a chance to read it? also, how do make it so it does not give the value in standard form, like it is doing at he moment?

thanks.


EDIT: i have added more functionality:

program AreaOfCircle (input, output);
const
pi = 3.1415926535897932384626433832795;
two = 2;


var
radius : real;
area : real;
volume : real;
circumference : real;



procedure pause;

begin
writeln('press any key to exit');
readln;
end;



begin
writeln('enter radius:');
readln(radius);
writeln;
writeln('circumference of circle =');
circumference := 2 * pi * radius;
writeln(circumference);
writeln;
writeln('area of circle =');
area := pi * radius * radius;
writeln(area);
writeln;
writeln('volume of sphere =');
volume := 4 / 3 * pi * radius * radius * radius;
writeln(volume);
writeln;
pause;

end.


the circumference does not work. it just outputs the value of pi. i have no idea why it does that.... :\ like so:



i have tried with the number "2", and having 2 as a constant, and neither way works, it just gives me pi.

EDIT EDIT: the circumference has now randomly started working... i didn't even change anything...

i am quite proud of that, i have only been coding for 2 hours.

EDIT EDIT EDIT: ok, there was never a problem with the circumference, it was just the numbers i was using.

i just want to know how to non-standard form it now.
__________________
Q66@3.4/P5K Prem/4GB(850)/98GTX/Xonar D2/4TB
Quad 33+303/KEF Celeste IV/Denon D2000

last.fm
joshd is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On